:root {
  --bg: #f4f5f7;
  --panel: #fff;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e3e6ec;
  --accent: #2f5bea;
  --danger: #d43c3c;
  --warn: #c98200;
  --ok: #138a52;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
pre { background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font-size: 12px; max-height: 480px; white-space: pre-wrap; word-break: break-word; }

/* шапка */
.top { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 52px; background: #161c2b; color: #fff; position: sticky; top: 0; z-index: 10; }
.top .brand { color: #fff; font-weight: 700; font-size: 16px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: #c5cbd8; padding: 6px 12px; border-radius: 6px; }
.top nav a:hover { text-decoration: none; background: rgba(255,255,255,.08); color: #fff; }
.top nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.top .me { display: flex; gap: 12px; align-items: center; color: #c5cbd8; }
.top .me .link { color: #c5cbd8; }

main { max-width: 1440px; margin: 0 auto; padding: 20px; }

/* общи */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 480px; margin: 60px auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; color: var(--ink); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 48px; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font: inherit; color: var(--ink); }
.btn:hover { border-color: #c9ceda; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.link.danger { color: var(--danger); }

input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=color] { padding: 2px; height: 38px; }
label { display: block; color: var(--muted); font-size: 12px; }
label > input, label > select, label > textarea { margin-top: 4px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; padding-top: 18px; }
label.inline { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
label.inline input { margin: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: #e8f6ee; color: #0d5c37; border: 1px solid #bfe6cf; }
.flash.error { background: #fdecec; color: #9b2222; border-color: #f4c4c4; }
.flash.warn { background: #fff6e0; color: #7a5200; border-color: #f1dca4; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); border: 1px solid color-mix(in srgb, var(--c) 30%, #fff); }
.site { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.site::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.flag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 4px; margin-left: 4px; }
.flag.danger { background: #fdecec; color: var(--danger); }
.flag.warn { background: #fff3d6; color: var(--warn); }
.flag.info { background: #e9effd; color: var(--accent); }
.flag.ok { background: #e8f6ee; color: var(--ok); }
.flag.block { display: block; margin: 0 0 8px; padding: 6px 10px; font-size: 13px; }

/* таблици */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card .table-wrap { border: 0; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
tr.risky { background: #fff8f8; }
tr.off td { opacity: .55; }
td.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th.chk, td.chk { width: 32px; padding-right: 0; }
tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
tr.strong td { font-weight: 700; }

/* филтри и табове */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { width: 260px; }
.filters select, .filters input[type=date] { width: auto; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { --c: var(--ink); padding: 6px 12px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.tabs a b { color: var(--muted); font-weight: 600; margin-left: 4px; }
.tabs a:hover { text-decoration: none; border-color: var(--c); }
.tabs a.on { border-color: var(--c); box-shadow: inset 0 -3px 0 var(--c); }

.bulkbar { display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin-bottom: 10px; background: #161c2b; color: #fff; border-radius: var(--radius); position: sticky; top: 60px; z-index: 5; }
.bulkbar select { width: auto; }
.pager { display: flex; justify-content: center; gap: 20px; padding: 16px; color: var(--muted); }

/* страница на поръчка */
.page-head { margin-bottom: 16px; }
.page-head.row { display: flex; justify-content: space-between; align-items: center; }
.back { font-size: 13px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.fields .wide { grid-column: span 2; }
.note { background: #fff8e5; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.status-opt { display: block; cursor: pointer; }
.status-opt input { position: absolute; opacity: 0; }
.status-opt span { display: block; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); color: var(--ink); font-size: 13px; }
.status-opt input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); color: var(--c); font-weight: 600; }
.status-opt input:focus-visible + span { outline: 2px solid var(--c); }
aside textarea { margin-bottom: 10px; }
.blacklist { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.others, .history { list-style: none; margin: 0; padding: 0; }
.others li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.history li:last-child, .others li:last-child { border-bottom: 0; }
.raw summary { cursor: pointer; font-weight: 600; }
.raw pre { margin-top: 12px; }

/* сайтове */
.copy-row { display: flex; gap: 8px; margin-bottom: 12px; }
.copy-row input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.steps { color: var(--muted); padding-left: 18px; line-height: 1.6; }
.mapping td { vertical-align: middle; }
.mapping select { min-width: 220px; }
form.card > .btn, form.card > button.btn { margin-top: 6px; }
.card > h2 + .table-wrap { margin-bottom: 16px; }

/* вход */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { width: 340px; display: grid; gap: 14px; }
.login h1 { justify-content: center; }

@media (max-width: 1000px) {
  .grid { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr 1fr; }
  .top { gap: 12px; padding: 0 12px; }
  .top .me span { display: none; }
  main { padding: 12px; }
  .filters input[type=search] { width: 100%; }
}
.bulkbar[hidden] { display: none; }
@media (max-width: 700px) {
  .top .brand { display: none; }
  .top nav { overflow-x: auto; }
  .top nav a { padding: 6px 8px; }
  .fields { grid-template-columns: 1fr; }
  .fields .wide { grid-column: auto; }
  table.orders { min-width: 860px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
}
.setup { width: min(620px, 94vw); display: grid; gap: 14px; margin: 30px 0; }
.setup h2 { margin: 6px 0 0; }
.fields.two { grid-template-columns: 1fr 1fr; margin: 0; }
.checks td { padding: 4px 8px; border: 0; }
