:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #14181f;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #f14635;      /* Kaspi red */
  --accent-d: #d63724;
  --win: #15a34a;
  --win-bg: #e9f7ef;
  --lose: #dc2626;
  --lose-bg: #fdecec;
  --tie: #d97706;
  --tie-bg: #fdf3e6;
  --neutral: #64748b;
  --neutral-bg: #eef1f5;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --radius: 12px;
  --topbar-h: 61px;
  --controls-h: 86px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }
.topbar .meta { color: var(--muted); font-size: 12px; text-align: right; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 8px; transition: .15s;
}
.btn:hover { border-color: #cfd3da; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn:disabled { opacity: .55; cursor: default; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 24px 60px; }

.tabs { display: inline-flex; gap: 6px; margin: 0 0 12px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.tab.active { background: var(--ink); color: #fff; }

/* toolbar */
.sticky-controls { position: sticky; top: var(--topbar-h); z-index: 15; background: var(--bg); padding: 4px 0 6px; margin: -4px 0 4px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chipset { display: inline-flex; align-items: center; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--neutral);
  padding: 6px 13px; border-radius: 999px 0 0 999px; font-size: 13px; font-weight: 600;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { opacity: .6; margin-left: 5px; font-weight: 700; }
.chip-xls {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  border: 1px solid #107c41;
  border-left: 0;
  background: #fff;
  color: #107c41;
  padding: 6px 9px;
  border-radius: 0 999px 999px 0;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.chip-xls:hover { text-decoration: none; background: #ecfdf3; color: #0b6f38; }
.search { flex: 1; min-width: 160px; }
.search input {
  width: 100%; padding: 9px 13px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 13px; background: #fff;
}

/* table */
.tablecard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: visible; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.col-product { width: auto; }
.col-sale { width: 132px; }
.col-buybox { width: 126px; }
.col-cities { width: 86px; }
.col-price { width: 112px; }
.col-gap { width: 118px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
th { position: sticky; top: calc(var(--topbar-h) + var(--controls-h)); z-index: 12; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; cursor: pointer; user-select: none; white-space: nowrap; background: #fbfbfc; box-shadow: 0 1px 0 var(--line); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafbfc; }
td:not(.name) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.name { min-width: 0; }
td.name .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
td.name .sku { color: var(--muted); font-size: 11px; }

.badge { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.winning, .badge.alone { background: var(--win-bg); color: var(--win); }
.badge.losing { background: var(--lose-bg); color: var(--lose); }
.badge.tie { background: var(--tie-bg); color: var(--tie); }
.badge.absent { background: var(--neutral-bg); color: var(--neutral); }
.badge.sale.in_stock { background: var(--win-bg); color: var(--win); }
.badge.sale.out_of_stock, .badge.sale.absent { background: var(--neutral-bg); color: var(--neutral); }
.badge.sale.delisted { background: var(--lose-bg); color: var(--lose); }
.delta-pos { color: var(--lose); font-weight: 600; }
.delta-neg { color: var(--win); font-weight: 600; }
.muted { color: var(--muted); }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(16,24,40,.4); opacity: 0; pointer-events: none; transition: .2s; z-index: 40; }
.drawer-bg.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 560px; max-width: 94vw;
  background: var(--bg); box-shadow: -8px 0 30px rgba(16,24,40,.18);
  transform: translateX(100%); transition: .25s cubic-bezier(.4,0,.2,1); z-index: 50;
  overflow-y: auto; padding: 0;
}
.drawer.open { transform: translateX(0); }
.drawer .dh { position: sticky; top: 0; background: var(--card); border-bottom: 1px solid var(--line); padding: 18px 22px; display: flex; gap: 12px; align-items: flex-start; }
.drawer .dh h2 { margin: 0; font-size: 17px; line-height: 1.3; }
.drawer .dh .x { margin-left: auto; border: none; background: #eef1f5; width: 30px; height: 30px; border-radius: 8px; font-size: 16px; color: var(--muted); flex: none; }
.drawer .body { padding: 20px 22px; display: flex; flex-direction: column; gap: 18px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.panel h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.callout { border-radius: 10px; padding: 12px 14px; font-size: 13px; font-weight: 600; }
.callout.win { background: var(--win-bg); color: var(--win); }
.callout.lose { background: var(--lose-bg); color: var(--lose); }
.callout.tie { background: var(--tie-bg); color: var(--tie); }
.callout.absent { background: var(--neutral-bg); color: var(--neutral); }

.offer-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.offer-row:last-child { border-bottom: none; }
.offer-row .rank { width: 22px; color: var(--muted); font-weight: 700; text-align: center; }
.offer-row .mn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offer-row .pr { font-weight: 700; font-variant-numeric: tabular-nums; }
.offer-row.me { background: #fff7f6; margin: 0 -8px; padding: 8px; border-radius: 8px; border-bottom: none; }
.offer-row.me .mn { color: var(--accent); font-weight: 700; }
.city-offers { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.city-offers:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.city-offers-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 750; color: #334155; margin: 0 0 6px; }

.dist { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dist .r { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dist .bar { flex: 1; height: 7px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.dist .bar > span { display: block; height: 100%; background: #f5a623; }

.empty { text-align: center; padding: 50px; color: var(--muted); }
.spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
.btn:not(.primary) .spin { border-color: rgba(0,0,0,.2); border-top-color: var(--ink); }
@keyframes sp { to { transform: rotate(360deg); } }
.note { font-size: 12px; color: var(--muted); margin: 0 2px 6px; }

/* orders */
.orders-view { display: flex; flex-direction: column; gap: 12px; }
.orders-groups { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.order-group { min-height: 34px; border: 1px solid var(--line); border-radius: 18px; padding: 6px 12px; background: #fff; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.order-group span { margin-left: 4px; color: #98a2b3; font-variant-numeric: tabular-nums; }
.order-group.active { background: #18202b; border-color: #18202b; color: #fff; font-weight: 700; }
.order-group.active span { color: #d0d5dd; }
.orders-filters { display: grid; grid-template-columns: 140px 140px minmax(240px, 1fr) auto auto; gap: 8px; align-items: end; }
.orders-filter { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.orders-filter input, .orders-filter select { height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font-size: 13px; color: var(--ink); background: #fff; font-family: inherit; }
.orders-search { min-width: 220px; }
.orders-excel { color: #107c41; border-color: #8bc6a5; font-weight: 750; text-decoration: none; justify-content: center; }
.orders-excel:hover { background: #edf8f1; }
.orders-freshness { color: var(--muted); font-size: 12px; margin-top: -4px; }
.orders-kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.orders-kpi-tile { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; box-shadow: var(--shadow); }
.orders-kpi-tile .k { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.orders-kpi-tile .v { font-size: 22px; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.orders-table tbody tr { cursor: pointer; }
.orders-table tbody tr.active { background: #fff7f6; }
.orders-table { min-width: 920px; }
.orders-view .tablecard { overflow: visible; }
.orders-table th { top: var(--topbar-h); z-index: 18; cursor: default; }
.badge.order-status.new { background: #fff4d6; color: #8a5b00; }
.badge.order-status.accepted { background: #e8f2ff; color: #175cd3; }
.badge.order-status.completed { background: var(--win-bg); color: var(--win); }
.badge.order-status.cancelled { background: var(--lose-bg); color: var(--lose); }
.badge.order-status.other { background: #eef1f5; color: #475467; }
.orders-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order-detail-bg { position: fixed; inset: 0; z-index: 90; background: rgba(16,24,40,.48); display: flex; align-items: center; justify-content: center; padding: 18px; }
.order-detail-modal { width: min(900px, 96vw); max-height: 94vh; background: #fff; border-radius: 8px; box-shadow: 0 22px 70px rgba(16,24,40,.32); display: flex; flex-direction: column; overflow: hidden; }
.order-detail-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.order-detail-head h2 { margin: 0; font-size: 20px; }
.order-detail-eyebrow { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.order-detail-head .x { margin-left: auto; border: none; background: #eef1f5; width: 32px; height: 32px; border-radius: 8px; font-size: 20px; color: var(--muted); cursor: pointer; }
.order-detail-scroll { overflow: auto; }
.order-detail-section { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.order-detail-section h3 { margin: 0 0 12px; font-size: 14px; }
.order-status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0 14px; }
.order-status-line > span:first-child { width: 150px; color: var(--muted); font-size: 12px; }
.order-status-line > b { color: #b54708; font-size: 12px; }
.order-info-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.order-info-grid > div { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(150px, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.order-info-grid > div:nth-child(odd) { padding-right: 18px; }
.order-info-grid > div:nth-child(even) { padding-left: 18px; border-left: 1px solid var(--line); }
.order-info-grid span { color: var(--muted); font-size: 12px; }
.order-info-grid b { font-size: 13px; text-align: right; }
.order-info-grid b small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.order-info-grid.compact > div { border-bottom: 0; }
.order-items-head, .order-item { display: grid; grid-template-columns: minmax(260px, 1fr) 105px 70px 105px; gap: 12px; align-items: center; }
.order-items-head { padding: 8px 0; color: var(--muted); font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.order-items { display: flex; flex-direction: column; }
.order-item { border-bottom: 1px dashed var(--line); padding: 12px 0; font-size: 13px; }
.order-item:last-child { border-bottom: 0; }
.order-product-name { min-width: 0; }
.order-product-name a { color: #0782c1; text-decoration: none; font-weight: 650; }
.order-product-name a:hover { text-decoration: underline; }
.order-mobile-label { display: none; }
.order-history-head, .order-history-row { display: grid; grid-template-columns: 180px minmax(180px, 1fr) minmax(140px, 1fr); gap: 14px; }
.order-history-head { padding: 8px 0; color: var(--muted); font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.order-history-row { padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.order-history-row:last-child { border-bottom: 0; }
.order-delivery-details { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.order-delivery-details p { margin: 0; font-size: 13px; line-height: 1.5; }
.order-detail-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line); }
.order-detail-actions .muted { margin-right: auto; }
.order-detail-actions a { text-decoration: none; }
.order-detail-loading, .order-detail-error { padding: 40px 20px; text-align: center; color: var(--muted); }
.order-detail-loading .spin { display: inline-block; border-color: rgba(0,0,0,.15); border-top-color: var(--ink); vertical-align: middle; margin-right: 8px; }

/* reapply modal */
.reapply-modal-bg { position: fixed; inset: 0; z-index: 80; background: rgba(16,24,40,.42); display: flex; align-items: center; justify-content: center; padding: 18px; }
.reapply-modal { width: min(860px, 96vw); max-height: 90vh; background: var(--card); border-radius: var(--radius); box-shadow: 0 18px 60px rgba(16,24,40,.28); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0 0 4px; font-size: 18px; }
.modal-head .x { margin-left: auto; border: none; background: #eef1f5; width: 30px; height: 30px; border-radius: 8px; font-size: 16px; color: var(--muted); flex: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.reapply-tools { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.reapply-list { overflow: auto; padding: 8px 12px; }
.reapply-row { display: grid; grid-template-columns: 24px minmax(180px, 1fr) 150px 110px; align-items: center; gap: 10px; padding: 10px 8px; border-bottom: 1px solid var(--line); cursor: pointer; }
.reapply-row:last-child { border-bottom: none; }
.reapply-row:hover { background: #fafbfc; }
.reapply-row.is-delisted { background: #fff7f6; }
.reapply-main { min-width: 0; }
.reapply-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reapply-status { min-width: 0; }
.reapply-price { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* city tally in table */
td.cities { white-space: nowrap; }
.cities .ct { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.ct.win { color: var(--win); }
.ct.tie { color: var(--tie); }
.ct.lose { color: var(--lose); }
.ct.ab { color: var(--neutral); }
.place { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.place.win { color: var(--win); }
.place.tie { color: var(--tie); }
.place.lose { color: var(--lose); }
.sub2 { font-size: 11px; color: var(--muted); font-weight: 400; }

/* per-city table in drawer */
.citytbl { width: 100%; border-collapse: collapse; table-layout: auto; }
.citytbl td { padding: 7px 6px; border-bottom: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
.citytbl td:first-child { font-variant-numeric: normal; }
.citytbl tr:last-child td { border-bottom: none; }
.city-row { cursor: pointer; }
.city-row:hover { background: #fafbfc; }
.city-row.focus { background: #fff7f6; }
.badge.sm { padding: 2px 7px; font-size: 11px; }

/* price control */
.pricectl .ov-status { font-size: 13px; margin-bottom: 12px; }
.ov-set { color: var(--accent); font-weight: 700; }
.ov-del { color: var(--lose); font-weight: 700; }
.priceform { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.priceform input { flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-variant-numeric: tabular-nums; }
.priceform select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; background: #fff; }
.city-dropdown { position: relative; min-width: 240px; flex: 1 1 240px; }
.city-drop-btn { width: 100%; height: 38px; padding: 8px 34px 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; text-align: left; font-size: 13px; color: var(--ink); position: relative; }
.city-drop-btn::after { content: '▾'; position: absolute; right: 11px; top: 8px; color: var(--muted); }
.city-drop-menu { display: none; position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; max-height: 260px; overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: var(--shadow); }
.city-dropdown.open .city-drop-menu { display: block; }
.city-check { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.city-check:hover { background: #f8fafc; }
.city-check.all { font-weight: 700; border-bottom: 1px solid var(--line); margin-bottom: 4px; padding-bottom: 7px; }
.city-check input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); flex: 0 0 auto; }
.pc-actions { display: flex; gap: 8px; }
.pc-actions .btn { flex: 1; justify-content: center; }
.btn.relist { background: var(--win); border-color: var(--win); color: #fff; }
.pc-note { font-size: 12px; margin-top: 10px; line-height: 1.4; }
.pc-result { margin-top: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13px; border: 1px solid var(--line); background: #f8fafc; }
.pc-result.pending { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.pc-result.ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.pc-result.err { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.pc-log { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 12px; }
.pc-log-title { font-weight: 700; margin-bottom: 5px; color: #475569; }
.pc-log-row { display: grid; grid-template-columns: 74px 1fr 1.2fr; gap: 8px; padding: 4px 0; border-bottom: 1px dashed #e5e7eb; }
.pc-log-row:last-child { border-bottom: 0; }
.pc-log-row.ok span:last-child { color: #166534; }
.pc-log-row.err span:last-child { color: #b91c1c; }

/* topbar extras */
.topbar { flex-wrap: wrap; }
.citysel-wrap { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.citysel { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; color: var(--ink); font-family: inherit; }

/* source marker (сопоставлено по названию) */
.srcmark { background: #fef3c7; color: #92400e; border-radius: 6px; padding: 1px 6px; font-size: 10px; font-weight: 700; margin-left: 6px; vertical-align: middle; }
.srcnote { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 9px 12px; font-size: 12px; }
.srcnote a { color: #b45309; font-weight: 700; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,40,.45); opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
.modal-bg.open { opacity: 1; pointer-events: auto; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-48%) scale(.98); width: 640px; max-width: 94vw; max-height: 86vh; overflow-y: auto; background: var(--card); border-radius: 14px; box-shadow: 0 20px 60px rgba(16,24,40,.3); z-index: 70; opacity: 0; pointer-events: none; transition: .18s; }
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%,-50%) scale(1); }
.modal .mh { position: sticky; top: 0; background: var(--card); padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; z-index: 1; }
.modal .mh h2 { margin: 0; font-size: 16px; }
.modal .mh .x { margin-left: auto; border: none; background: #eef1f5; width: 30px; height: 30px; border-radius: 8px; font-size: 16px; color: var(--muted); }
.modal .mb { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }

.sugg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.sugg .cat { font-weight: 700; margin-bottom: 8px; }
.sugg .cat .sku { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.cand { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; cursor: pointer; }
.cand input { margin: 0; flex: none; }
.cand .ct { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand .cf { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cand .pr { font-weight: 600; white-space: nowrap; }
.sugg .acts { display: flex; gap: 8px; margin-top: 10px; }
.sugg .acts .btn { font-size: 12px; padding: 6px 12px; }
.btn.ok { background: var(--win); border-color: var(--win); color: #fff; }
.btn.no { color: var(--lose); border-color: #f3c9c9; }

@media (max-width: 900px) {
  th.hide, td.hide { display: none; }
  .orders-table { min-width: 0; }
  .reapply-row { grid-template-columns: 24px minmax(0, 1fr); }
  .reapply-status, .reapply-price { grid-column: 2; text-align: left; }
}

@media (max-width: 700px) {
  :root { --topbar-h: 0px; --controls-h: 0px; }
  body { font-size: 13px; }

  .topbar {
    position: static;
    gap: 8px;
    padding: 10px 12px;
  }
  .brand {
    width: 100%;
    font-size: 15px;
  }
  .brand small {
    max-width: 58vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .citysel-wrap { order: 2; flex: 1 1 150px; }
  .citysel { width: 100%; min-width: 0; }
  .topbar .spacer { display: none; }
  .topbar .meta { order: 3; flex: 1 1 100%; text-align: left; }
  .topbar .btn {
    order: 4;
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
    min-height: 40px;
    padding: 8px 10px;
  }
  .topbar .btn.primary { flex-basis: 100%; }

  .wrap { padding: 10px 10px 40px; }
  .sticky-controls {
    position: sticky;
    top: 0;
    margin: 0 0 8px;
    padding: 8px 0;
  }
  .toolbar { gap: 8px; }
  .tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .tab { width: 100%; }
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip {
    padding: 7px 11px;
    font-size: 12px;
  }
  .chipset { flex: 0 0 auto; }
  .chip-xls { padding: 7px 8px; }
  .search { flex: 1 1 100%; }
  .search input { height: 40px; font-size: 14px; }
  .note { font-size: 11px; line-height: 1.35; }

  .tablecard {
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 0;
  }
  table, tbody, tr, td { display: block; width: 100%; }
  colgroup, thead { display: none; }
  tbody tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 9px;
    padding: 10px 12px;
  }
  tbody tr:hover { background: var(--card); }
  th, td { border-bottom: 0; padding: 0; }
  td:not(.name) {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    overflow: visible;
    white-space: normal;
    padding-top: 8px;
  }
  td:not(.name)::before {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
  }
  td.name {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }
  td.name .nm { font-size: 14px; line-height: 1.25; white-space: normal; }
  td.name .sku { margin-top: 3px; font-size: 12px; }
  td:nth-child(2)::before { content: 'Статус'; }
  td:nth-child(3)::before { content: 'Buy-box'; }
  td:nth-child(4)::before { content: 'Города'; }
  td:nth-child(5)::before { content: 'Моя цена'; }
  td:nth-child(6)::before { content: 'Разрыв'; }
  td.num { text-align: left; }
  td.cities { white-space: normal; }
  .cities .ct { margin-right: 7px; }
  .sub2 { display: inline; margin-left: 5px; }
  .badge { width: fit-content; max-width: 100%; }

  .drawer {
    width: 100vw;
    max-width: none;
    border-radius: 0;
  }
  .drawer .dh { padding: 14px 14px; align-items: center; }
  .drawer .dh h2 { font-size: 16px; }
  .drawer .body { padding: 14px 12px 28px; gap: 12px; }
  .panel { padding: 13px 12px; border-radius: 10px; }
  .callout { padding: 10px 11px; }
  .citytbl { display: table; min-width: 520px; }
  .citytbl tbody { display: table-row-group; }
  .citytbl tr { display: table-row; width: auto; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .citytbl td { display: table-cell; width: auto; padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
  .citytbl td::before { content: none; }
  .panel:has(.citytbl) { overflow-x: auto; }
  .offer-row { gap: 8px; }
  .offer-row .mn { white-space: normal; }
  .priceform { display: grid; grid-template-columns: 72px 1fr; }
  .priceform input { grid-column: 1; }
  .city-dropdown { grid-column: 2; min-width: 0; flex-basis: auto; }
  .priceform .btn { grid-column: 1 / -1; justify-content: center; min-height: 40px; }
  .pc-actions { flex-direction: column; }
  .pc-log-row { grid-template-columns: 62px 1fr; }
  .pc-log-row span:last-child { grid-column: 1 / -1; }

  .reapply-modal-bg { align-items: stretch; padding: 0; }
  .reapply-modal {
    width: 100vw;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
  }
  .modal-head { padding: 14px 12px; }
  .modal-head h2 { font-size: 17px; }
  .reapply-tools { padding: 10px 12px; }
  .reapply-tools .btn { flex: 1 1 auto; justify-content: center; }
  .reapply-list { padding: 4px 8px; }
  .modal-actions {
    padding: 10px 12px;
    gap: 8px;
  }
  .modal-actions .btn { flex: 1; justify-content: center; min-height: 40px; }

  .modal {
    width: 100vw;
    max-width: none;
    max-height: 100dvh;
    border-radius: 0;
  }

  .orders-filters { grid-template-columns: 1fr 1fr; }
  .orders-filter.orders-search { grid-column: 1 / -1; }
  #ordersApply, .orders-excel { width: 100%; justify-content: center; min-height: 40px; }
  .orders-kpi { grid-template-columns: 1fr 1fr; }
  .orders-pager { flex-wrap: wrap; }
  .orders-table { min-width: 0; }
  .orders-table td { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; align-items: start; margin: 5px 0; text-align: left; }
  .orders-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 650; }
  .order-detail-bg { align-items: stretch; padding: 0; }
  .order-detail-modal { width: 100vw; max-height: none; height: 100dvh; border-radius: 0; }
  .order-detail-head, .order-detail-section, .order-detail-actions { padding-left: 14px; padding-right: 14px; }
  .order-info-grid { grid-template-columns: 1fr; }
  .order-info-grid > div, .order-info-grid > div:nth-child(odd), .order-info-grid > div:nth-child(even) { padding: 10px 0; border-left: 0; }
  .order-info-grid > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .order-info-grid b { text-align: left; }
  .order-items-head, .order-history-head { display: none; }
  .order-item { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: start; }
  .order-product-name { grid-column: 1 / -1; }
  .order-mobile-label { display: block; color: var(--muted); font-size: 10px; margin-bottom: 2px; }
  .order-history-row { grid-template-columns: 1fr; gap: 4px; }
  .order-delivery-details { grid-template-columns: 1fr; gap: 18px; }
  .order-detail-actions { flex-wrap: wrap; }
  .order-detail-actions .muted { width: 100%; margin: 0; }
  .order-detail-actions .btn { width: 100%; justify-content: center; min-height: 42px; }
}

@media print {
  @page { size: A4 portrait; margin: 7mm; }
  html, body { width: 100%; margin: 0; padding: 0; background: #fff; font-size: 10px; }
  body > * { display: none !important; }
  body > .order-detail-bg { display: block !important; position: static; inset: auto; padding: 0; background: #fff; }
  .order-detail-modal { width: 100%; max-width: none; max-height: none; height: auto; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
  .order-detail-head { padding: 0 0 7px; border-bottom: 1px solid #999; }
  .order-detail-head h2 { font-size: 17px; }
  .order-detail-eyebrow { font-size: 9px; }
  .order-detail-head .x, .order-detail-actions { display: none !important; }
  .order-detail-scroll { overflow: visible; }
  .order-detail-section { padding: 7px 0; break-inside: avoid; page-break-inside: avoid; }
  .order-detail-section h3 { margin-bottom: 5px; font-size: 11px; }
  .order-status-line { padding: 3px 0 6px; gap: 6px; }
  .order-status-line > span:first-child { width: 105px; font-size: 9px; }
  .badge { padding: 2px 6px; font-size: 9px; }
  .order-info-grid > div { padding: 4px 0; gap: 6px; }
  .order-info-grid > div:nth-child(odd) { padding-right: 9px; }
  .order-info-grid > div:nth-child(even) { padding-left: 9px; }
  .order-info-grid span, .order-info-grid b { font-size: 9px; }
  .order-info-grid b small { font-size: 8px; }
  .order-items-head, .order-item { grid-template-columns: minmax(230px, 1fr) 80px 45px 80px; gap: 7px; }
  .order-items-head { padding: 4px 0; font-size: 8px; }
  .order-item { padding: 5px 0; font-size: 9px; break-inside: avoid; page-break-inside: avoid; }
  .order-product-name .sub2 { font-size: 8px; }
  .order-history-head, .order-history-row { grid-template-columns: 125px minmax(150px, 1fr) minmax(110px, 1fr); gap: 7px; }
  .order-history-head { padding: 4px 0; font-size: 8px; }
  .order-history-row { padding: 4px 0; font-size: 9px; }
  .order-delivery-details { gap: 14px; }
  .order-delivery-details p { font-size: 9px; line-height: 1.3; }
  a { color: #000 !important; text-decoration: none !important; }
}
