:root {
  --paper: #f5f6fa;
  --surface: #ffffff;
  --ink: #1b1a2e;
  --muted: #6b6880;
  --line: #e1e0ea;
  --ad: #6c4cf1;
  --product: #e0882b;
  --mention: #1f9d8b;
  --ok: #1f8a63;
  --warn: #b77a0f;
  --bad: #cf3f37;
  --focus: #6c4cf1;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14131f; --surface: #1c1b2a; --ink: #ecebf5; --muted: #a29fb8; --line: #2e2c42;
    --ad: #9a83ff; --product: #f0a24a; --mention: #3cc2ad; --ok: #3cc28a; --warn: #e2a63a;
    --bad: #f0675f; --focus: #9a83ff; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 "Onest", system-ui, sans-serif; font-feature-settings: "tnum" 1;
}
a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--ad); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 4vw, 2.6rem); letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar .wrap { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font-weight: 800; letter-spacing: -0.02em; text-decoration: none; }
.brand span { color: var(--ad); }
.topbar nav { margin-left: auto; display: flex; gap: 16px; font-size: 0.9rem; }
main { padding: 32px 0 80px; }
.stack > * + * { margin-top: 24px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
         padding: 20px; }
.panel > h2 + * { margin-top: 16px; }

/* кнопки й поля */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
       background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 8px;
       font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.primary:hover { background: var(--ad); border-color: var(--ad); color: #fff; }
.btn.ok { color: var(--ok); } .btn.ok:hover { border-color: var(--ok); }
.btn.bad { color: var(--bad); } .btn.bad:hover { border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
form.inline { display: inline; }
label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; margin-top: 4px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox] { width: auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad);
         padding: 10px 14px; border-radius: 8px; }
.notice { background: color-mix(in srgb, var(--ad) 10%, transparent); padding: 10px 14px;
          border-radius: 8px; }

/* таблиці */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8rem;
     padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.quote { max-width: 46ch; min-width: 26ch; color: var(--muted); }

/* формати: кольорова мітка */
.fmt { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.fmt::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.f-ad { --c: var(--ad); } .f-product { --c: var(--product); } .f-mention { --c: var(--mention); }

.status { font-size: 0.8rem; font-weight: 600; padding: 2px 8px; border-radius: 99px;
          white-space: nowrap; border: 1px solid currentColor; }
.s-auto, .s-confirmed, .t-ok { color: var(--ok); }
.s-pending, .t-warn { color: var(--warn); }
.s-rejected, .t-bad { color: var(--bad); }
.t-muted { color: var(--muted); }
.s-rejected ~ * { opacity: .6; }

/* стрічка стріму — головний елемент */
.strip { position: relative; height: 34px; background: color-mix(in srgb, var(--ink) 6%, transparent);
         border-radius: 6px; margin: 8px 0 22px; }
.strip .tick { position: absolute; top: 0; bottom: -18px; border-left: 1px dashed var(--line); }
.strip .tick span { position: absolute; bottom: 0; left: 4px; font-size: 0.7rem; color: var(--muted);
                    white-space: nowrap; }
.strip a.ev { position: absolute; top: 4px; bottom: 4px; min-width: 6px; border-radius: 3px;
              background: var(--c); text-decoration: none; }
.strip a.ev:hover, .strip a.ev:focus-visible { top: 0; bottom: 0; box-shadow: 0 0 0 2px var(--surface); }
.strip a.ev.pending { background: repeating-linear-gradient(135deg, var(--c) 0 3px, transparent 3px 6px);
                      outline: 1px solid var(--c); }
.strip-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
              flex-wrap: wrap; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }

/* план / факт */
.pf { display: grid; grid-template-columns: minmax(170px, 1.2fr) 2fr auto; gap: 8px 18px;
      align-items: center; }
.pf .bar { height: 8px; background: color-mix(in srgb, var(--ink) 8%, transparent);
           border-radius: 99px; overflow: hidden; position: relative; }
.pf .bar i { position: absolute; inset: 0 auto 0 0; background: var(--c); border-radius: 99px; }
.pf .bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.pf .nums { white-space: nowrap; font-size: 0.9rem; }
.pf .nums strong { font-size: 1.05rem; }

/* перевірка */
.review-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; }
.player { aspect-ratio: 16 / 9; background: color-mix(in srgb, var(--ink) 8%, transparent);
          border-radius: 8px; display: grid; place-items: center; overflow: hidden; }
.player iframe { width: 100%; height: 100%; border: 0; }
@media (max-width: 760px) { .review-item { grid-template-columns: 1fr; } }

/* сторінка клієнта */
.client-hero { padding: 48px 0 8px; }
.client-hero .brandname { font-size: clamp(2.4rem, 7vw, 4.4rem); font-weight: 800;
                          letter-spacing: -0.035em; line-height: 1; }
.totals { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 28px; }
.totals div strong { display: block; font-size: 2rem; font-weight: 700; line-height: 1.1; }
.totals div { border-left: 3px solid var(--c); padding-left: 12px; }
.footer { border-top: 1px solid var(--line); padding: 24px 0 40px; font-size: 0.85rem;
          color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .strip a.ev { transition: top .12s, bottom .12s; }
}

/* список подій на сторінці клієнта */
.evlist { list-style: none; margin: 0 0 8px; padding: 0; }
.evlist li { display: grid; grid-template-columns: 88px 1fr; column-gap: 16px; padding: 10px 0;
             border-bottom: 1px solid var(--line); }
.evlist li:last-child { border-bottom: 0; }
.evlist .vw, .evlist .quote { grid-column: 2; }
.evlist .vw:empty { display: none; }
.evlist .quote { margin-top: 4px; max-width: 70ch; }
@media (min-width: 760px) {
  .evlist li { grid-template-columns: 88px 230px 130px 1fr; align-items: baseline; }
  .evlist .vw { grid-column: 3; grid-row: 1; text-align: right; }
  .evlist .vw:empty { display: block; }
  .evlist .quote { grid-column: 4; grid-row: 1; margin: 0; }
}
.filters select { width: auto; }
@media (max-width: 640px) {
  .pf { grid-template-columns: 1fr; gap: 4px; }
  .pf .bar { order: 0; grid-column: auto; margin-bottom: 4px; }
  .pf .nums { white-space: normal; margin-bottom: 12px; }
  .strip .tick span { display: none; }
  .strip .tick:nth-of-type(2n) span { display: inline; }
  .totals { gap: 16px 24px; }
}

/* формат, який можна змінити */
.fmt-edit select { width: auto; border: 1px solid transparent; background: transparent;
  padding: 2px 22px 2px 4px; margin-left: -4px; font: inherit; cursor: pointer; }
.fmt-edit select:hover, .fmt-edit select:focus-visible { border-color: var(--line);
  background: var(--paper); }

/* вкладки кампанії */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600;
          border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

/* зведення по стрімерах */
table.summary th.grp { text-align: left; border-bottom: 2px solid var(--c); }
table.summary td, table.summary th { white-space: nowrap; }
table.summary tfoot th, table.summary tfoot td { border-top: 2px solid var(--ink); font-weight: 600; }
.sm-cell { display: grid; gap: 4px; min-width: 84px; }
.minibar { height: 4px; background: color-mix(in srgb, var(--ink) 8%, transparent); border-radius: 99px;
           overflow: hidden; display: block; }
.minibar i { display: block; height: 100%; background: var(--c, var(--ink)); }
table.summary td:last-child { white-space: normal; min-width: 130px; }
table.summary tfoot th { border-bottom: 0; }
table.summary td, table.summary th { padding-left: 8px; padding-right: 8px; }
