:root {
  --ink: #171715;
  --rail: #151716;
  --rail-soft: #202321;
  --paper: #f7f3ed;
  --paper-strong: #fffdf9;
  --line: #ddd6cc;
  --line-strong: #c7bfb3;
  --muted: #746e66;
  --muted-strong: #5e5952;
  --accent: #bd332a;
  --accent-dark: #9d241d;
  --accent-soft: #f5dfd9;
  --positive: #16843a;
  --positive-soft: #e1f2e6;
  --warning: #ae691e;
  --warning-soft: #f5e7d3;
  --danger: #b52c26;
  --radius: 10px;
  --shadow: 0 18px 50px rgba(10, 10, 9, .16);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--rail); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--rail); color: var(--ink); font: 15px/1.45 var(--sans); }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid rgba(189, 51, 42, .38); outline-offset: 2px; }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; background: #111312; }
.sidebar { min-height: 100vh; display: flex; flex-direction: column; padding: 34px 22px 24px; color: #e7e5e0; }
.brand { display: inline-flex; flex-direction: column; width: fit-content; padding: 0 14px 27px; color: #faf7f0; border-bottom: 1px solid rgba(255,255,255,.16); }
.brand:hover { color: #fff; }
.brand-word { font: 700 34px/.9 var(--serif); letter-spacing: .13em; }
.brand-caption { margin-top: 10px; color: #aaa9a4; font-size: 9px; font-weight: 700; letter-spacing: .19em; }
.main-nav { display: grid; gap: 4px; margin-top: 26px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 15px; min-height: 50px; padding: 0 14px; border-radius: 7px; color: #c5c5bf; font-size: 15px; transition: color .16s ease, background .16s ease; }
.nav-link:hover { background: rgba(255,255,255,.055); color: #fff; }
.nav-link.is-active { color: #f05246; background: rgba(255,255,255,.07); }
.nav-link.is-active::before { content: ""; position: absolute; left: -22px; width: 4px; height: 30px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-icon { width: 20px; text-align: center; font-size: 20px; line-height: 1; color: currentColor; }
.sidebar-footer { margin-top: auto; display: grid; gap: 22px; padding: 22px 10px 0; border-top: 1px solid rgba(255,255,255,.14); }
.location-mark { display: flex; align-items: flex-start; gap: 11px; font-size: 12px; color: #cdcbc5; }
.location-mark strong { display: block; color: #f5f3ed; font-weight: 600; }
.location-mark small { display: block; color: #9f9f99; margin-top: 2px; font-size: 11px; }
.location-icon { font-size: 17px; }
.account-link { display: flex; justify-content: space-between; color: #b8b8b2; font-size: 13px; }
.account-link:hover { color: #fff; }

.workspace { min-width: 0; margin: 18px 18px 18px 0; padding: 40px 48px 46px; border-radius: 13px; background: var(--paper); box-shadow: var(--shadow); }
.page { max-width: 1450px; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.page-header h1 { margin: 2px 0 7px; font: 700 clamp(38px, 4vw, 53px)/1 var(--serif); letter-spacing: -.05em; }
.header-actions { display: flex; flex-shrink: 0; flex-wrap: wrap; gap: 10px; }
.page-subtitle { max-width: 700px; margin: 0; color: var(--muted); font-size: 16px; }
.section-label { margin: 0 0 9px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 45px 0 17px; }
.section-heading h2, .publication-intro h2, .publication-action h2 { margin: 0; font: 700 29px/1.1 var(--serif); letter-spacing: -.035em; }
.muted { color: var(--muted); }
.muted a { text-decoration: underline; text-underline-offset: 3px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 650; transition: transform .14s ease, box-shadow .14s ease, color .14s ease, background .14s ease, border-color .14s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .42; transform: none; }
.button-primary { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 7px 15px rgba(165, 38, 31, .2); }
.button-primary:hover { background: var(--accent-dark); color: #fff; }
.button-quiet { border-color: var(--line); background: rgba(255,255,255,.35); }
.button-quiet:hover, .button-small:hover { border-color: var(--line-strong); background: var(--paper-strong); color: var(--ink); }
.button-small { min-height: 32px; padding: 0 11px; border-color: var(--line); background: var(--paper-strong); font-size: 12px; }
.button-danger { color: var(--danger); }

.catalogue-tools { display: grid; grid-template-columns: minmax(220px, 1.38fr) repeat(4, minmax(126px, .72fr)) auto; gap: 11px; align-items: end; margin-bottom: 18px; }
.search-field, .field { display: grid; gap: 6px; }
.field > span, .target-url > span { color: var(--muted-strong); font-size: 12px; font-weight: 700; }
.input-wrap { position: relative; }
.input-wrap::before { content: "⌕"; position: absolute; left: 13px; top: 50%; transform: translateY(-51%); color: var(--muted); font-size: 22px; pointer-events: none; }
.input-wrap input { padding-left: 42px; }
input[type="text"], input[type="url"], input[type="number"], input[type="password"], select, textarea { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.46); color: var(--ink); outline: none; transition: border-color .14s ease, background .14s ease, box-shadow .14s ease; }
textarea { min-height: 110px; padding-top: 11px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(189,51,42,.1); }
.filter-submit { white-space: nowrap; }

.saved-views { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; }
.saved-views-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.view-link { display: inline-flex; align-items: center; gap: 6px; min-height: 31px; padding: 0 9px; border: 1px solid transparent; border-radius: 5px; color: var(--muted-strong); font-size: 12px; }
.view-link:hover, .view-link.is-active { border-color: var(--line); background: rgba(255,255,255,.48); color: var(--ink); }
.view-remove { border: 0; background: transparent; color: #9b9388; font-size: 15px; line-height: 1; }
.view-remove:hover { color: var(--accent); }
.save-view-button { margin-left: auto; }

.bulk-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 56px; padding: 10px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bulk-count { color: var(--muted); font-size: 13px; }
.bulk-count strong { color: var(--ink); }
.bulk-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.bulk-action { min-height: 31px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted-strong); font-size: 12px; font-weight: 700; }
.bulk-action:hover:not(:disabled) { background: rgba(189,51,42,.09); color: var(--accent-dark); }
.bulk-action.is-danger:hover:not(:disabled) { background: var(--accent-soft); color: var(--danger); }

.catalogue-wrap, .jobs-table-wrap { overflow-x: auto; }
.catalogue-table, .jobs-table { width: 100%; min-width: 880px; border-collapse: collapse; }
.catalogue-table th, .jobs-table th { padding: 15px 12px 13px; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .035em; text-align: left; white-space: nowrap; }
.catalogue-table td, .jobs-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.catalogue-table tbody tr { transition: background .14s ease; }
.catalogue-table tbody tr:hover { background: rgba(255,255,255,.46); }
.catalogue-table tbody tr.is-selected { background: rgba(213,201,185,.36); }
.checkbox { position: relative; display: inline-flex; width: 19px; height: 19px; }
.checkbox input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.checkbox span { width: 19px; height: 19px; border: 1px solid #bdb5a9; border-radius: 4px; background: transparent; }
.checkbox input:checked + span { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--paper); }
.drag-handle { width: 28px; height: 34px; border: 0; background: transparent; color: #afa89e; font-size: 16px; cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.product-cell { display: flex; align-items: center; gap: 13px; min-width: 250px; }
.product-image, .product-image-placeholder { width: 62px; height: 62px; flex: 0 0 62px; border-radius: 5px; object-fit: cover; background: #e2d9cc; }
.product-image-placeholder { display: grid; place-items: center; color: #776d61; font: 700 20px var(--serif); }
.product-name { display: block; font-weight: 750; }
.product-meta { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.price { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.availability { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.availability::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.availability.is-available::before { background: var(--positive); }
.visibility { color: var(--muted); font-size: 12px; }
.visibility.is-hidden { color: var(--danger); }
.row-menu { position: relative; display: inline-block; }
.row-menu summary { list-style: none; width: 34px; height: 32px; display: grid; place-items: center; border-radius: 5px; color: var(--muted-strong); cursor: pointer; font-size: 19px; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover { background: rgba(0,0,0,.055); }
.row-menu[open] > div { position: absolute; right: 0; top: 36px; z-index: 5; display: grid; min-width: 155px; padding: 5px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper-strong); box-shadow: 0 12px 25px rgba(34,27,18,.15); }
.row-menu a, .row-menu button { padding: 8px 9px; border: 0; border-radius: 4px; background: transparent; text-align: left; color: var(--ink); font-size: 13px; }
.row-menu a:hover, .row-menu button:hover { background: #f0ebe4; color: var(--ink); }
.row-menu .delete-link { color: var(--danger); }
.empty-catalogue, .empty-row td { padding: 50px 12px; color: var(--muted); text-align: center; }
.order-note { margin: 15px 0 0; color: var(--muted); font-size: 12px; }

.dialog { max-width: 420px; width: calc(100% - 36px); padding: 0; border: 0; border-radius: 12px; color: var(--ink); background: var(--paper-strong); box-shadow: 0 25px 60px rgba(0,0,0,.28); }
.dialog::backdrop { background: rgba(17,18,16,.45); }
.dialog form { display: grid; gap: 18px; padding: 25px; }
.dialog h2 { margin: 0; font: 700 28px/1.05 var(--serif); letter-spacing: -.035em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }

.form-layout { max-width: 870px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 19px 22px; padding: 29px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.form-grid .field-wide { grid-column: 1 / -1; }
.field-toggle { display: flex; align-items: center; gap: 11px; min-height: 44px; color: var(--muted-strong); font-size: 14px; }
.field-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding-top: 22px; }
.form-actions .actions-right { display: flex; gap: 10px; }
.image-preview { width: 112px; height: 112px; margin-top: 9px; border-radius: 7px; object-fit: cover; }

.categories-list { display: grid; gap: 0; max-width: 820px; border-top: 1px solid var(--line); }
.category-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 63px; border-bottom: 1px solid var(--line); }
.category-row strong { font-size: 16px; }
.category-form { display: grid; grid-template-columns: minmax(200px, 1fr) auto; gap: 10px; max-width: 820px; margin-bottom: 28px; }

.publication-intro { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 21px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.preflight { max-width: 540px; padding: 12px 15px; border-radius: 7px; font-size: 13px; }
.preflight ul { margin: 6px 0 0; padding-left: 18px; }
.preflight-error { border: 1px solid #e4b7ae; background: #fae8e3; color: #85231d; }
.preflight-ok { border: 1px solid #b8dabe; background: var(--positive-soft); color: #286c3b; }
.preflight-ok span { color: var(--positive); }
.target-list { margin-top: 4px; }
.target-row { display: grid; grid-template-columns: minmax(190px, .68fr) minmax(260px, 1.35fr) auto auto; align-items: end; gap: 18px; padding: 19px 0; border-top: 1px solid var(--line); }
.target-row:last-child { border-bottom: 1px solid var(--line); }
.target-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.platform-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 9px; color: #fff; font-size: 13px; font-weight: 850; }
.platform-mark.platform-yandex { background: #e8342d; }
.platform-mark.platform-2gis { background: #2686dc; }
.target-title h3 { margin: 0; font-size: 15px; }
.target-title p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.target-url { display: grid; gap: 6px; }
/* Специфичность не ниже, чем у `.target-url > span` выше, иначе та перекрасит подсказку. */
.target-url > .target-url-stale { color: var(--warning); font-size: 12px; font-weight: 500; }
.target-url > .target-url-stale code { font-size: 11px; word-break: break-all; }
.switch-control { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; white-space: nowrap; color: var(--muted-strong); font-size: 13px; font-weight: 700; }
.switch-control input { position: absolute; opacity: 0; }
.switch-track { position: relative; display: inline-block; width: 34px; height: 20px; border-radius: 20px; background: #c7c0b6; transition: background .16s ease; }
.switch-track span { position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .16s ease; }
.switch-control input:checked + .switch-track { background: var(--accent); }
.switch-control input:checked + .switch-track span { transform: translateX(14px); }
.publication-action { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-top: 34px; padding: 27px 29px; border: 1px solid #dfd1c3; border-radius: 9px; background: #f3e8dd; }
.publication-action h2 { margin-bottom: 8px; }
.publication-action p:not(.section-label) { max-width: 680px; margin: 0; color: var(--muted-strong); }
.jobs-table td { font-size: 13px; }
.job-detail { max-width: 380px; color: var(--muted-strong); }
.status-pill { display: inline-flex; align-items: center; min-height: 27px; padding: 0 9px; border-radius: 99px; background: #eee9e1; color: var(--muted-strong); font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-queued { background: #ece7df; }
.status-processing { background: var(--warning-soft); color: #8d5113; }
.status-succeeded { background: var(--positive-soft); color: #237138; }
.status-needs_manual { background: var(--accent-soft); color: #98251e; }
.status-failed { background: #fae0dc; color: #94221d; }

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: #111312; }
.login-panel { width: min(100%, 430px); padding: 41px; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); }
.login-brand { display: block; margin-bottom: 44px; color: var(--ink); font: 700 31px/1 var(--serif); letter-spacing: .11em; }
.login-panel h1 { margin: 0 0 8px; font: 700 37px/1 var(--serif); letter-spacing: -.04em; }
.login-panel p { margin: 0 0 27px; color: var(--muted); }
.login-panel form { display: grid; gap: 17px; }
.login-error { margin: 0 0 18px !important; padding: 10px 12px; border-radius: 6px; background: #fae0dc; color: #94221d !important; font-size: 13px; }

.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 100; display: grid; gap: 9px; max-width: min(380px, calc(100vw - 48px)); }
.toast { padding: 12px 14px; border-radius: 7px; background: #252724; color: #fff; box-shadow: 0 10px 25px rgba(0,0,0,.2); font-size: 13px; }
.toast.is-error { background: #962920; }
.toast.is-success { background: #216a37; }

@media (max-width: 1120px) {
  .workspace { padding: 34px 32px 40px; }
  .catalogue-tools { grid-template-columns: minmax(220px, 1fr) 1fr 1fr; }
  .catalogue-tools .search-field { grid-column: span 3; }
  .target-row { grid-template-columns: 1fr 1fr; }
  .target-row > .button { justify-self: start; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; padding: 18px 18px 0; }
  .brand { padding: 0 6px 16px; border: 0; }
  .brand-word { font-size: 27px; }
  .main-nav { grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 0 -4px; }
  .nav-link { justify-content: center; min-height: 44px; padding: 0 6px; gap: 7px; font-size: 12px; }
  .nav-link.is-active::before { left: 12px; bottom: 0; width: calc(100% - 24px); height: 3px; border-radius: 3px 3px 0 0; }
  .nav-icon { font-size: 16px; }
  .sidebar-footer { display: none; }
  .workspace { margin: 0; padding: 30px 19px 36px; border-radius: 0; }
  .page-header, .publication-intro, .publication-action { align-items: flex-start; flex-direction: column; }
  .page-header h1 { font-size: 43px; }
  .catalogue-tools { grid-template-columns: 1fr 1fr; }
  .catalogue-tools .search-field { grid-column: span 2; }
  .catalogue-tools .filter-submit { grid-column: span 2; }
  .bulk-toolbar { align-items: flex-start; flex-direction: column; }
  .save-view-button { margin-left: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .target-row { grid-template-columns: 1fr; gap: 12px; }
  .target-row > .button { width: 100%; }
  .publication-action { padding: 23px; }
  .publication-action .button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; padding: 22px 0; }
  .form-grid .field-wide { grid-column: auto; }
  .category-form { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .nav-link span:last-child { display: none; }
  .nav-link { min-height: 39px; }
  .nav-icon { font-size: 20px; }
  .page-header h1 { font-size: 39px; }
  .catalogue-tools { grid-template-columns: 1fr; }
  .catalogue-tools .search-field, .catalogue-tools .filter-submit { grid-column: auto; }
  .button { width: 100%; }
  .bulk-actions { width: 100%; }
  .bulk-action { flex: 1 1 42%; }
  .login-panel { padding: 30px 24px; }
}

.form-error {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fdecec;
  color: #8c1c13;
  font-size: 14px;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: #6b7280;
  font-size: 12px;
}

.photo-warning {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff4e5;
  color: #8a5300;
  font-size: 12px;
  white-space: nowrap;
}

.news-form {
  margin-bottom: 32px;
  padding: 24px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.news-body {
  margin: 0;
  padding: 16px;
  border-radius: 10px;
  background: #f7f8fa;
  font: inherit;
  white-space: pre-wrap;
}

