/* Консоль offers-hub в стиле whocpa.asia: токены сняты с landing.css сайта,
   акцент из брендбука — градиентный логотип и тонкая градиентная линия под шапкой. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("inter-cyrillic-wght-normal.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("inter-latin-wght-normal.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: #fff; --bg-soft: #fafafc; --card: #fff; --border: #ececf1;
  --ink: #171717; --muted: #5f6368; --faint: #9aa1ab;
  --purple: #7c3aed; --purple-dark: #6d28d9; --purple-soft: #f5f3ff; --purple-soft-2: #ede9fe;
  --focus: #c4b5fd; --success: #1a8d52; --success-soft: #e7f6ee; --danger: #e5484d;
  --danger-soft: #fdecec; --warn: #b45309; --warn-soft: #fff4e5;
  --brand-gradient: linear-gradient(90deg, #d60dfd, #2544d3);
  --radius: 18px; --radius-sm: 12px; --radius-xs: 8px;
  --shadow: 0 1px 2px rgba(16, 16, 24, .04), 0 8px 24px rgba(16, 16, 24, .05);
  --shadow-lg: 0 12px 40px rgba(76, 29, 149, .10);
  --topbar: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg-soft); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- элементы форм ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
.input, input[type="text"], input[type="password"], input[type="search"], input[type="url"],
input:not([type]), select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: var(--bg); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft-2);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
select { appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235f6368' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); font-weight: 400; }
.ro { margin: 0; padding: 9px 12px; border-radius: var(--radius-xs); background: var(--bg-soft);
  border: 1px dashed var(--border); white-space: pre-wrap; max-height: 180px; overflow: auto; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 11px; border: 1px solid var(--border); background: var(--bg);
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: #d9d4ee; background: var(--purple-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #f6c9ca; }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--purple-soft); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.icon { padding: 7px; width: 34px; height: 34px; }

/* переключатель вместо чекбокса */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 99px; background: #d6d8de; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .track { background: var(--purple); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

/* ---------- вход ---------- */
.login {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--purple-soft-2), transparent), var(--bg-soft);
}
.login-card {
  width: min(380px, 100%); background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 32px 28px 28px; display: grid; gap: 14px;
}
.login-card img { width: 102px; height: 48px; }
.login-card h1 { font-size: 22px; }
.login-card .btn { width: 100%; padding: 11px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 0; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar); background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand-gradient); opacity: .85; }
.topbar-inner { height: 100%; display: flex; align-items: center; gap: 20px; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand img { width: 68px; height: 32px; }
.brand span { padding-left: 10px; border-left: 1px solid var(--border); font-size: 15px; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.tabs a:hover { background: var(--purple-soft); color: var(--ink); text-decoration: none; }
.tabs a.active { background: var(--purple-soft-2); color: var(--purple-dark); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  padding: 6px 6px 6px 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--bg); }
.sync-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 99px; border: 1px solid var(--border); background: var(--bg); }
.menu > summary::-webkit-details-marker { display: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 700; font-size: 13px; background: var(--brand-gradient); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; display: grid; }
.menu-pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-pop button { text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.menu-pop button:hover { background: var(--purple-soft); }

/* ---------- страница ---------- */
.page { max-width: 1440px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; }
.page-head .spacer { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px;
  box-shadow: var(--shadow); cursor: pointer; text-align: left; transition: border-color .15s; }
.stat:hover { border-color: var(--focus); }
.stat.active { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft-2); }
.stat .num { font-size: 22px; font-weight: 700; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.bar { height: 4px; border-radius: 99px; background: var(--border); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--purple); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search { position: relative; flex: 1 1 260px; }
.search input { padding-left: 36px; }
.search::before { content: ""; position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239aa1ab' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l4 4'/%3E%3C/svg%3E") no-repeat; }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
kbd { font: 11px/1 "Inter", sans-serif; padding: 3px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; color: var(--muted); background: var(--bg); }
.toolbar select { width: auto; min-width: 140px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--bg-soft); border: 1px solid var(--border); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(16,16,24,.1); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.chip { border: 1px solid var(--border); background: var(--bg); border-radius: 99px; padding: 4px 11px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip:hover { border-color: var(--focus); }
.chip.on { background: var(--purple); border-color: var(--purple); color: #fff; }
.chip .n { font-weight: 500; opacity: .75; margin-left: 4px; }
.result-line { padding: 10px 16px; font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.result-line .btn { margin-left: auto; }

/* ---------- таблица ---------- */
/* На широком экране без своей прокрутки: иначе липкая шапка таблицы липнет к обёртке, а не к окну. */
.table-wrap { overflow: visible; }
.card { overflow: clip; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-soft); position: sticky; top: var(--topbar); z-index: 1; white-space: nowrap; }
table.grid td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.offers tbody tr { cursor: pointer; transition: background .1s; }
table.offers tbody tr:hover { background: var(--purple-soft); }
table.offers tbody tr.selected { background: var(--purple-soft-2); }
table.offers tbody tr.is-hidden td:not(:last-child) { opacity: .45; }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--bg-soft); border: 1px solid var(--border); display: grid; place-items: center; color: var(--faint); font-size: 18px; }
.offer-name { font-weight: 600; }
.offer-link { color: inherit; text-decoration: none; }
.offer-link:hover { color: var(--purple-dark); }
.offer-sub { font-size: 12px; color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.tag.geo { background: var(--purple-soft); border-color: var(--purple-soft-2); color: var(--purple-dark); }
.tag.ours { background: var(--success-soft); border-color: #cdebd9; color: var(--success); }
.tag.cover { background: var(--purple); border-color: var(--purple); color: #fff; }
.fill { display: inline-flex; gap: 4px; }
.fill i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.fill i.on { background: var(--success); }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.skeleton td div { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #f0f0f4, #f7f7fa, #f0f0f4); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- выезжающая панель оффера ---------- */
.scrim { position: fixed; inset: 0; background: rgba(23, 23, 23, .28); z-index: 30; animation: fade .15s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); z-index: 31; background: var(--card);
  box-shadow: -12px 0 40px rgba(16, 16, 24, .12); display: flex; flex-direction: column; animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { padding: 18px 22px 0; border-bottom: 1px solid var(--border); }
.drawer-title { display: flex; gap: 14px; align-items: flex-start; }
.drawer-title .thumb { width: 56px; height: 56px; }
.drawer-title h2 { font-size: 19px; line-height: 1.3; }
.drawer-title .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.drawer-title .close { margin-left: auto; }
.drawer-tabs { display: flex; gap: 2px; margin-top: 14px; }
.drawer-tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.drawer-tabs button.on { color: var(--purple-dark); border-bottom-color: var(--purple); }
.drawer-tabs .count { font-weight: 500; color: var(--faint); margin-left: 4px; }
.drawer-body { flex: 1; overflow: auto; padding: 20px 22px 28px; display: grid; gap: 16px; align-content: start; }
.drawer-body .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 6px; }
.note { padding: 10px 12px; border-radius: var(--radius-xs); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.savebar { display: flex; gap: 10px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--card); }
.savebar .state { color: var(--muted); font-size: 13px; }
.savebar .state.dirty { color: var(--warn); font-weight: 600; }
.savebar .btn.danger { margin-left: auto; }

/* материалы */
.drop { border: 2px dashed #d9d4ee; border-radius: var(--radius-sm); padding: 22px; text-align: center; background: var(--purple-soft); color: var(--muted); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--purple); background: var(--purple-soft-2); }
.drop b { color: var(--ink); }
.drop .btn { margin-top: 10px; }
.uploads { display: grid; gap: 6px; }
.upload { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.upload .bar { grid-column: 1 / -1; margin: 0; }
.upload.err { color: var(--danger); }
.mats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.mat { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--card); display: flex; flex-direction: column; }
.mat.is-cover { border-color: var(--purple); box-shadow: 0 0 0 2px var(--purple-soft-2); }
.mat-preview { position: relative; aspect-ratio: 4 / 3; background: var(--bg-soft); display: grid; place-items: center; color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 12px; }
.mat-preview img { width: 100%; height: 100%; object-fit: cover; }
.mat-preview .tag { position: absolute; left: 8px; top: 8px; }
.mat-info { padding: 8px 10px 4px; font-size: 12px; min-width: 0; }
.mat-info b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-info span { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-actions { display: flex; gap: 4px; padding: 4px 6px 8px; }
.mat-actions .btn { flex: 1; }
.link-add { display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; }

/* ---------- ниши и люди ---------- */
.inline-input { max-width: 360px; }
.saved-mark { font-size: 12px; color: var(--success); margin-left: 8px; }
table.people td .input, table.people td select { min-width: 140px; }

/* ---------- диалоги и тосты ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; box-shadow: var(--shadow-lg); width: min(440px, calc(100% - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(23, 23, 23, .32); }
.dlg { padding: 22px; display: grid; gap: 14px; }
.dlg h3 { font-size: 18px; }
.dlg p { margin: 0; color: var(--muted); }
.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; }
.toast { min-width: 240px; max-width: 420px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); animation: slide .2s ease-out; font-size: 13px; white-space: pre-wrap; }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

/* ---------- узкие экраны ---------- */
@media (max-width: 900px) {
  .table-wrap { overflow-x: auto; }
  table.grid th { position: static; }
  .topbar-inner { gap: 10px; padding: 0 14px; }
  .brand span, .sync-chip .label { display: none; }
  .page { padding: 16px 12px; }
  .col-niche, .col-price { display: none; }
}
@media (max-width: 600px) {
  :root { --topbar: 104px; }
  .topbar { height: auto; }
  .topbar-inner { flex-wrap: wrap; padding: 10px 12px; height: auto; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .col-fill { display: none; }
  #whoShort { display: none; }
  .menu > summary { padding: 3px; }
  table.grid td, table.grid th { padding: 10px; }
  .drawer-body .row2, .link-add { grid-template-columns: 1fr; }
  .toasts { left: 12px; right: 12px; }
}
table.offers td:first-child, table.offers th:first-child { width: 1%; padding-right: 4px; }
