/* CRM возвратов BIP#39 — тёмный интерфейс в стиле сервиса счетов. Без эмодзи, телефон — карточки. */

@font-face {
  font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/Inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/Inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                 U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0b0b0b; --surface: #171717; --surface-2: #212121; --surface-3: #1e1e1e;
  --line: #272727; --line-2: #383838;
  --text: #ffffff; --text-2: #dfdfdf; --muted: #a0a0a0; --dim: #8a8a8a; --faint: #666;
  --orange: #ff7a00; --orange-hi: #fc9235; --purple: #d5a0fa;
  --green: #4caf82; --green-bg: #0d2e1a;
  --red: #f47070; --red-bg: #2e0d0d;
  --yellow: #fed876; --yellow-bg: #2a2200;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.5; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange-hi); }
h1 { font-size: 22px; font-weight: 700; margin-bottom: 14px; letter-spacing: -.2px; }
h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 12px 0 8px; color: var(--text-2); }

/* ---------- шапка ---------- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 12px 24px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand img { height: 24px; display: block; }
.brand .title { font-size: 15px; font-weight: 700; color: var(--text); }
.topbar nav {
  display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px;
}
.topbar nav a { padding: 7px 14px; border-radius: 10px; font-weight: 500; color: var(--dim); white-space: nowrap; }
.topbar nav a:hover { color: var(--text); }
.topbar nav a.on { background: linear-gradient(135deg, var(--orange), var(--purple)); color: #fff; font-weight: 600; }
.who { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.who a { color: var(--muted); }
.who .out {
  padding: 6px 14px; border: 1px solid var(--line-2); border-radius: 20px; background: transparent;
  color: var(--muted); font-weight: 500; font-size: 13px;
}
.who .out:hover { border-color: var(--red); color: var(--red); background: transparent; }
.statusbar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding: 6px 24px; background: #121212; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--dim);
}
.sync.bad { color: var(--red); font-weight: 600; }
.drybadge { color: var(--yellow); background: var(--yellow-bg); padding: 2px 10px; border-radius: 12px; font-weight: 600; }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; text-align: center; }
.pill.red { background: var(--red); color: #111; font-weight: 700; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 16px 56px; }
.narrow { max-width: 440px; margin: 0 auto; padding: 56px 16px; }

/* ---------- карточки, формы, кнопки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(213, 160, 250, .12); }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.7); }
select option { background: var(--surface-2); color: var(--text); }
.row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.row > div { flex: 1 1 180px; min-width: 0; }

button, .btn {
  display: inline-block; padding: 11px 22px; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.3;
  border: 1px solid transparent; border-radius: 30px; background: var(--orange); color: #fff; cursor: pointer;
  text-align: center;
}
button:hover, .btn:hover { background: var(--orange-hi); color: #fff; }
.btn-ghost, button.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line-2); }
.btn-ghost:hover, button.btn-ghost:hover { background: transparent; border-color: var(--orange); color: var(--orange); }
.btn-sm, button.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-danger, button.btn-danger { background: transparent; color: var(--red); border-color: var(--line-2); }
.btn-danger:hover, button.btn-danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
button.btn-reject { background: #c44545; }
button.btn-reject:hover { background: #d85a5a; }
.btn.disabled { background: var(--surface-2); color: var(--faint); border-color: var(--line); cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.w-100 { width: 100%; }
.w-num { width: 120px !important; }
.w-pw { width: 160px !important; }

.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--orange); flex-shrink: 0; }
.check label { margin: 0; color: var(--text-2); font-size: 14px; font-weight: 400; }
label.check { color: var(--text-2); font-weight: 400; margin: 0; }
.check.ack { background: var(--red-bg); border: 1px solid var(--red); border-radius: 10px; padding: 12px; }
.inline-label { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-label input { width: auto; }

.flashes { margin-bottom: 16px; }
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 13px; background: var(--red-bg); color: var(--red); }
.flash.ok { background: var(--green-bg); color: var(--green); }

.alert { padding: 11px 14px; border-radius: 10px; margin: 10px 0; font-size: 14px; border: 1px solid; }
.alert.red { background: var(--red-bg); color: var(--red); border-color: #5a2020; }
.alert.yellow { background: var(--yellow-bg); color: var(--yellow); border-color: #4a3c00; }
.alert.green { background: var(--green-bg); color: var(--green); border-color: #1d5a37; }
.alert.grey { background: var(--surface-2); color: var(--text-2); border-color: var(--line-2); }
.alert.big { font-size: 17px; font-weight: 700; text-align: center; }
.dry-banner {
  margin: 10px 0 16px; padding: 14px; border-radius: 12px; text-align: center; font-size: 18px; font-weight: 800;
  letter-spacing: .5px; color: #111; background: repeating-linear-gradient(135deg, #fed876, #fed876 14px, #f1c84f 14px, #f1c84f 28px);
}
.dry-note { color: var(--yellow); margin-bottom: 10px; }
.drytag { font-size: 11px; color: var(--yellow); background: var(--yellow-bg); padding: 1px 8px; border-radius: 10px; white-space: nowrap; }

/* ---------- счётчики, вкладки, фильтры ---------- */
.counters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cnt { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; color: var(--muted); }
.cnt b { color: var(--text); font-size: 18px; margin-right: 4px; }
.cnt.hot { border-color: #5a2020; background: var(--red-bg); color: var(--red); }
.cnt.hot b { color: var(--red); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 9px 14px; color: var(--dim); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.on { color: var(--text); border-bottom-color: var(--orange); }
.tabs .n { font-size: 12px; color: var(--faint); margin-left: 2px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; padding: 8px 10px; }

/* ---------- таблицы ---------- */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mb { margin-bottom: 16px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; padding: 10px 12px; background: var(--surface-2); font-size: 11px; font-weight: 500;
  color: var(--faint); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.list td { padding: 11px 12px; border-bottom: 1px solid #222; color: var(--text-2); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: var(--surface-3); }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }
table.list tr.reopened td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.rowlink { color: var(--text); font-weight: 600; }
.rowlink:hover { color: var(--orange); }
.empty { padding: 36px; text-align: center; color: var(--dim); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* ---------- таймеры и метки ---------- */
.timer { font-weight: 700; white-space: nowrap; }
.t-overdue, .t-lt6h { color: var(--red); }
.t-lt24h { color: var(--yellow); }
.t-ok { color: var(--green); }
.t-none, .t-None { color: var(--faint); font-weight: 500; }
.guess { font-size: 11px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line-2); padding: 0 6px; border-radius: 8px; white-space: nowrap; }
.big-timer .timer { font-size: 22px; }
.mp { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 8px; white-space: nowrap; }
.mp-wb { background: #3a1036; color: #f08ae0; }
.mp-ozon { background: #0d2050; color: #7fa6ff; }
.mp-ym { background: #3a2a00; color: #ffd24a; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 8px; background: #1e1028; color: var(--purple); }
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.yellow { background: var(--yellow-bg); color: var(--yellow); }
.tag.green { background: var(--green-bg); color: var(--green); }
.tag.grey { background: var(--surface-2); color: var(--dim); }
.st { font-size: 12px; padding: 1px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.st-open { color: var(--orange); }
.st-reopened { background: var(--red-bg); color: var(--red); }
.st-sending { color: var(--yellow); }
.st-decided, .st-closed_manual { color: var(--green); }
.ast { font-size: 12px; color: var(--text-2); }
.ast-confirmed { color: var(--green); }
.ast-failed, .ast-stale, .ast-unknown, .ast-unconfirmed { color: var(--red); }
.ast-awaiting_admin, .ast-queued, .ast-prechecking, .ast-sending, .ast-sent_ok { color: var(--yellow); }
.ast-dry_run_ok, .ast-cancelled { color: var(--muted); }
.how { font-size: 12px; white-space: nowrap; }
.how.api { color: var(--green); }
.how.cab { color: var(--yellow); }
.red-text { color: var(--red); }

/* ---------- карточка заявки ---------- */
.head-top { display: flex; gap: 20px; justify-content: space-between; flex-wrap: wrap; }
.head-meta { margin-bottom: 4px; color: var(--text-2); }
.head-timer { min-width: 240px; max-width: 380px; }
.basis { margin-top: 4px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.kv > div { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-bottom: 1px solid #222; }
.kv > div:last-child { border-bottom: 0; }
.kv > div > span:first-child { color: var(--dim); font-size: 13px; }
.quote { margin-top: 12px; padding: 12px 14px; background: var(--surface-2); border-left: 3px solid var(--purple); border-radius: 8px; white-space: pre-wrap; word-break: break-word; }
.pre { white-space: pre-wrap; word-break: break-word; }
.d-block { display: block; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line-2); display: block; }
.lightbox { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .9); align-items: center; justify-content: center; padding: 16px; }
.lightbox:target { display: flex; }
.lightbox img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border: 0; }
.video { width: 100%; max-height: 420px; margin-top: 12px; border-radius: 10px; background: #000; }
ul.plain { list-style: none; }
ul.plain li { padding: 5px 0; border-bottom: 1px solid #222; }
ul.plain li:last-child { border-bottom: 0; }
.hist li { font-size: 13px; }
.decide-btns { display: flex; flex-direction: column; gap: 6px; }
.decide-btns .btn { width: 100%; text-align: left; border-radius: 12px; }
.btn.act-approve { background: #1f6b47; }
.btn.act-approve:hover { background: #27845a; }
.btn.act-reject { background: #8f2f2f; }
.btn.act-reject:hover { background: #a83a3a; }
.btn.no-return { box-shadow: inset 0 0 0 2px var(--red); }
.btn.act-other { background: var(--surface-2); border-color: var(--line-2); color: var(--text); }
.btn.act-other:hover { border-color: var(--orange); }
.opt-hint { margin: -2px 4px 8px; }
details > summary { cursor: pointer; color: var(--muted); }
details.manual { border-top: 1px solid var(--line); padding-top: 12px; }
details.manual summary { font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
form.pass select { width: auto; min-width: 150px; padding: 7px 10px; }

/* ---------- форма решения и подтверждение ---------- */
.form-card { max-width: 760px; }
.field { margin: 16px 0; border: 0; }
fieldset.field legend { font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.req { font-size: 11px; color: var(--orange); font-weight: 600; }
label.radio { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 10px; margin-bottom: 6px; color: var(--text-2); font-weight: 400; cursor: pointer; }
label.radio input { margin-top: 3px; accent-color: var(--orange); }
.confirm-head { font-size: 18px; font-weight: 600; margin: 8px 0 14px; line-height: 1.45; }
.counter { margin-left: 6px; }

/* ---------- ход отправки ---------- */
ol.steps { list-style: none; margin: 14px 0; }
ol.steps li { padding: 7px 0 7px 30px; position: relative; color: var(--faint); }
ol.steps li::before { content: ""; position: absolute; left: 6px; top: 12px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); }
ol.steps li.step-done { color: var(--text-2); }
ol.steps li.step-done::before { background: var(--green); border-color: var(--green); }
ol.steps li.step-now { color: var(--yellow); font-weight: 600; }
ol.steps li.step-now::before { border-color: var(--yellow); }
ol.steps li.step-fail { color: var(--red); font-weight: 600; }
ol.steps li.step-fail::before { background: var(--red); border-color: var(--red); }
pre.code { background: #0f0f0f; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; margin-top: 8px; color: var(--text-2); }
.admin-box { border: 1px solid #4a3c00; background: #17140a; border-radius: 12px; padding: 16px; }

/* ---------- мелочи ---------- */
.muted { color: var(--dim); }
.small { font-size: 12.5px; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }
.mb-s { margin-bottom: 4px; }
.nowrap { white-space: nowrap; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { height: 32px; }
.ozon-link { padding: 12px 16px; }

/* ---------- телефон: таблицы превращаются в карточки ---------- */
@media (max-width: 900px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .statusbar { padding: 6px 12px; }
  .wrap { padding: 14px 10px 40px; }
  .cols { grid-template-columns: 1fr; }
  .head-timer { min-width: 0; max-width: none; }
}
@media (max-width: 760px) {
  table.rwd thead { display: none; }
  table.rwd, table.rwd tbody, table.rwd tr, table.rwd td { display: block; width: 100%; }
  table.rwd tr { border-bottom: 1px solid var(--line-2); padding: 8px 4px; }
  table.rwd tr:last-child { border-bottom: 0; }
  table.rwd td { border: 0; padding: 4px 10px; text-align: left; }
  table.rwd td.num { text-align: left; white-space: normal; }
  table.rwd td::before { content: attr(data-l); display: block; color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
  table.rwd td:not([data-l])::before { content: none; }
  table.list tr.reopened td:first-child { box-shadow: none; }
  table.list tr.reopened { box-shadow: inset 3px 0 0 var(--red); }
  .kv > div { grid-template-columns: 1fr; gap: 2px; }
  .filters select, .filters input { flex: 1 1 140px; min-width: 0; }
  .counters .cnt { flex: 1 1 140px; }
  h1 { font-size: 19px; }
  .big-timer .timer { font-size: 19px; }
  .w-pw { width: 130px !important; }
}

/* строка списка — целиком ссылка на заявку */
tr.rowclick { cursor: pointer; }
tr.rowclick:hover td { background: rgba(255, 255, 255, .03); }
.lightbox .lb-close { position: absolute; top: 10px; left: 0; right: 0; text-align: center; color: #ddd; font-size: 13px; }

/* переписка спора ЯМ */
.chat-msgs { margin: 8px 0 0; padding: 0; list-style: none; }
.chat-msg { border-left: 3px solid rgba(255, 255, 255, .15); padding: 6px 10px; margin: 0 0 8px; }
.chat-msg.chat-support { border-left-color: #f47070; }
.chat-msg.chat-partner { border-left-color: #6fcf97; }
.chat-msg.chat-market { border-left-color: rgba(255, 255, 255, .3); opacity: .85; }
.chat-text { white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
