/* ─── Карта потерь WB/Ozon — design tokens + base styles ──────────── */

:root {
  /* canvas */
  --bg:            #F4F5F7;
  --bg-2:          #ECEEF2;
  --surface:       #FFFFFF;
  --surface-soft:  #FAFBFC;
  --line:          #E4E7EC;
  --line-soft:     #EEF0F3;

  /* ink */
  --ink:           #0B1220;
  --ink-2:         #2A3142;
  --ink-3:         #5A6478;
  --ink-4:         #8893A6;
  --ink-5:         #B5BDCC;

  /* accent (default Indigo — overridable via Tweaks) */
  --accent:        #2E4BD9;
  --accent-2:      #1B33A8;
  --accent-soft:   #E8ECFB;
  --accent-ink:    #FFFFFF;

  /* status */
  --red:           #C5384C;
  --red-soft:      #FCEBEE;
  --amber:         #B86B14;
  --amber-soft:    #FBEFD9;
  --green:         #1F8A5B;
  --green-soft:    #E1F2E8;
  --blue:          #2B6FDB;
  --blue-soft:     #E4EEFB;
  --gray-soft:     #EEF0F3;

  /* type */
  --font-sans: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-disp: "Manrope", ui-sans-serif, system-ui, sans-serif;

  /* radii / shadow */
  --r-sm: 6px;
  --r:    10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --shadow-sm: 0 1px 0 rgba(11, 18, 32, 0.04);
  --shadow:    0 1px 2px rgba(11, 18, 32, 0.06), 0 0 0 1px rgba(11, 18, 32, 0.04);
  --shadow-lg: 0 12px 30px -10px rgba(11, 18, 32, 0.18), 0 4px 12px -4px rgba(11, 18, 32, 0.08);
}

* { box-sizing: border-box; }

html, body, #root {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
input, select, textarea {
  font: inherit;
  color: inherit;
}
input::placeholder, textarea::placeholder {
  color: var(--ink-4);
  opacity: 1;
  font-weight: 400;
}

/* ─── App shell ─── */
.app {
  display: grid;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  min-width: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-size: 13px;
}
.brand-text .b1 { font-weight: 700; }
.brand-text .b2 { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background:
    radial-gradient(circle at 30% 30%, #fff 0 22%, transparent 23%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: auto 4px 4px auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 2px var(--surface);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
  min-width: 0;
  white-space: nowrap;
}
.crumbs .sep { color: var(--ink-5); }
.crumbs .now { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumbs .meta {
  margin-left: auto;
  display: flex; gap: 14px; align-items: center;
  color: var(--ink-3);
  flex-shrink: 0;
  font-size: 12.5px;
}
.crumbs .meta b { color: var(--ink); font-weight: 600; }

.topbar-actions {
  display: flex; gap: 8px; align-items: center;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-soft); border-color: var(--ink-5); color: var(--ink); }
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.btn:disabled:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn.primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn.accent:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn .ico { width: 16px; height: 16px; stroke-width: 1.75; }

/* ─── Layout ─── */
.workspace {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 0;
}

.sidenav {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow: auto;
}
.sidenav-section {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-4);
  padding: 14px 10px 6px;
}
.sidenav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  white-space: nowrap;
}
.sidenav-item > span:not(.count) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidenav-item:hover { background: var(--surface-soft); }
.sidenav-item.active {
  background: var(--ink);
  color: #fff;
}
.sidenav-item.active .count { color: rgba(255,255,255,.7); }
.sidenav-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.sidenav-item .ico { width: 16px; height: 16px; stroke-width: 1.75; opacity: .9; }

.main {
  min-width: 0;
  padding: 28px 32px 80px;
  overflow: auto;
}
.main.narrow { max-width: 1200px; margin: 0 auto; }

/* ─── Page header ─── */
.page-h {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-h h1 {
  font-family: var(--font-disp);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.page-h .sub {
  color: var(--ink-3);
  font-size: 14px;
  max-width: 680px;
}
.page-h .right { display: flex; gap: 8px; align-items: center; }

/* ─── Card ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.card-pad { padding: 18px 20px; }
.card-h {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-h h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.card-h .sub { color: var(--ink-3); font-size: 13px; }

/* ─── Pill / badge ─── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gray-soft);
  color: var(--ink-3);
  line-height: 1.2;
  white-space: nowrap;
}
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.pill.red   { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.blue  { background: var(--blue-soft); color: var(--blue); }
.pill.gray  { background: var(--gray-soft); color: var(--ink-3); }
.pill.outline { background: var(--surface); border: 1px solid var(--line); color: var(--ink-3); }
.pill.lg { font-size: 13px; padding: 5px 11px; }

/* tiny chip for sources / impacts */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip svg { width: 11px; height: 11px; stroke-width: 2; }

/* ─── Metric / summary ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi .label {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi .value {
  font-family: var(--font-disp);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .delta { font-size: 12px; color: var(--ink-3); }
.kpi .delta.red { color: var(--red); }
.kpi .delta.green { color: var(--green); }
.kpi.featured {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.kpi.featured .label { color: rgba(255,255,255,.6); }
.kpi.featured .delta { color: rgba(255,255,255,.7); }
.kpi.featured .ring { position: absolute; right: -30px; top: -30px; width: 140px; height: 140px; border-radius: 50%; border: 1px solid rgba(255,255,255,.08); }
.kpi.featured .ring2 { position: absolute; right: -50px; top: -50px; width: 180px; height: 180px; border-radius: 50%; border: 1px solid rgba(255,255,255,.06); }

/* ─── Funnel viz ─── */
.funnel {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 22px;
}
.funnel-stage {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 14px 12px;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: border-color .15s, background .15s, transform .15s;
}
.funnel-stage:hover { border-color: var(--ink-4); }
.funnel-stage.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.funnel-stage.active .funnel-name { color: #fff; }
.funnel-stage.active .funnel-num { color: rgba(255,255,255,.7); }
.funnel-stage.active .funnel-bar { background: rgba(255,255,255,.18); }
.funnel-stage.active .funnel-bar > i { background: #fff; }
.funnel-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.08em;
}
.funnel-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2px 0 8px;
}
.funnel-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.funnel-bar {
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.funnel-bar > i {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
  transition: width .4s ease;
}
.funnel-arrow {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-4);
  z-index: 2;
}
.funnel-stage:last-child .funnel-arrow { display: none; }

/* ─── Tabs (in-page) ─── */
.tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 10px;
  gap: 2px;
}
.tab {
  height: 32px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(11,18,32,.06);
}

/* ─── Filter bar ─── */
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.filter {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.filter:hover { border-color: var(--ink-4); }
.filter.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.filter .num {
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.filter.on .num { color: rgba(255,255,255,.7); }
.filter-row .spacer { flex: 1; }
.search {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: 220px;
}
.search input {
  border: 0; outline: 0; width: 100%; background: transparent;
  font-size: 13px;
}

/* ─── Checklist item ─── */
.cl-list { display: flex; flex-direction: column; }
.cl-section {
  display: grid;
  grid-template-columns: 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 14px;
  overflow: hidden;
}
.cl-section-h {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-soft);
}
.cl-section-h .stage-num {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cl-section-h h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.cl-section-h .sub { color: var(--ink-3); font-size: 12.5px; margin-left: auto; }

.cl-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .12s;
  text-align: left;
  width: 100%;
  background: var(--surface);
}
.cl-item:last-child { border-bottom: 0; }
.cl-item:hover { background: var(--surface-soft); }
.cl-item.selected { background: var(--accent-soft); }

.cl-check {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--ink-5);
  display: grid; place-items: center;
  background: #fff;
  margin-top: 1px;
  flex-shrink: 0;
}
.cl-check.ok { background: var(--green); border-color: var(--green); color: #fff; }
.cl-check.needswork { background: #fff; border-color: var(--red); color: var(--red); }
.cl-check.needswork::after { content: "!"; font-weight: 800; font-size: 12px; line-height: 1; }
.cl-check.inprogress { background: #fff; border-color: var(--amber); color: var(--amber); }
.cl-check.inprogress::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
.cl-check.ok::after { content: ""; width: 8px; height: 4px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.cl-check.na { background: var(--gray-soft); border-color: var(--ink-5); color: var(--ink-4); }
.cl-check.na::after { content: "—"; font-size: 12px; line-height: 1; }

.cl-body { min-width: 0; }
.cl-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -0.003em;
  margin-bottom: 6px;
}
.cl-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cl-aside {
  display: flex; align-items: center; gap: 8px;
}
.cl-symptom {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ─── Drawer ─── */
.scrim {
  position: fixed; inset: 0;
  background: rgba(11, 18, 32, 0.4);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.scrim.on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: drawer-in .22s cubic-bezier(.2,.7,.2,1);
}
@keyframes drawer-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.drawer-h {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: flex-start; gap: 12px;
}
.drawer-h h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.drawer-h .meta { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.drawer-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--ink-3);
}
.drawer-close:hover { background: var(--surface-soft); color: var(--ink); }
.drawer-body { flex: 1; overflow: auto; padding: 18px 20px 80px; }
.drawer-section { margin-bottom: 22px; }
.drawer-section h5 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-4);
  font-weight: 700;
}
.drawer-section p { margin: 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.55; }
.drawer-section .note {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
  font-style: italic;
}

.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.kv {
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.kv .k { font-size: 11px; color: var(--ink-4); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kv .v { margin-top: 3px; font-size: 13.5px; font-weight: 600; color: var(--ink); }

.status-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.status-row.five {
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.status-row.five .status-opt .lbl { font-size: 12px; }
.status-row.five .status-opt .hint { font-size: 11px; }
.status-row.five .status-opt { padding: 8px 8px; }

/* Recommended action */
.reco-box {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 12px 14px;
}
.reco-box p { color: var(--ink) !important; font-weight: 500; font-size: 13.5px !important; }

/* Manual data fields */
.manual-data { display: flex; flex-direction: column; gap: 8px; }
.manual-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) minmax(140px, 200px);
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-2);
}
.manual-row > span { white-space: normal; line-height: 1.35; }
.manual-row input {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  font-size: 12.5px;
  outline: none;
  width: 100%;
}
.manual-row input:focus {
  border-color: var(--ink);
  background: var(--surface);
}

/* History mini */
.hist-mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}
.hist-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line-soft);
}
.hist-row:last-child { border-bottom: 0; }
.hist-when { color: var(--ink-4); font-family: var(--font-mono); font-size: 11px; }
.hist-what { color: var(--ink-2); }
.status-opt {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer;
  text-align: left;
  background: var(--surface);
}
.status-opt:hover { border-color: var(--ink-4); }
.status-opt.on {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.status-opt .lbl { font-size: 13px; font-weight: 600; }
.status-opt .hint { font-size: 11.5px; color: var(--ink-3); }
.status-opt.on .hint { color: rgba(255,255,255,.7); }

.drawer-f {
  border-top: 1px solid var(--line-soft);
  padding: 12px 20px;
  display: flex; gap: 8px;
  background: var(--surface);
}

/* ─── Empty / state cues ─── */
.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  padding: 36px;
  text-align: center;
  color: var(--ink-3);
}

/* ─── Formula card (DRR) ─── */
.formula {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 22px;
}
.formula-left {
  padding: 22px 24px;
  background: var(--ink);
  color: #fff;
  display: flex; flex-direction: column; gap: 14px;
}
.formula-eq {
  font-family: var(--font-mono);
  font-size: 14px;
  background: rgba(255,255,255,.06);
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1);
  line-height: 1.7;
}
.formula-eq .frac { display: inline-flex; flex-direction: column; vertical-align: middle; margin: 0 4px; text-align: center; }
.formula-eq .frac .num { border-bottom: 1px solid rgba(255,255,255,.4); padding: 0 8px 2px; }
.formula-eq .frac .den { padding: 2px 8px 0; }

.formula-right {
  padding: 22px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field label {
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field input, .field select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 12px;
  background: var(--surface);
  outline: none;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-weight: 500;
}
.field input:focus, .field select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11,18,32,.08);
}
.field .suffix-input {
  position: relative;
}
.field .suffix-input input { padding-right: 28px; }
.field .suffix-input .suffix {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--ink-4); font-size: 12px;
}
.segmented {
  display: inline-flex; padding: 3px; background: var(--bg-2); border-radius: 9px; gap: 2px;
}
.segmented button {
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}
.segmented button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(11,18,32,.08); }

.formula-result {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--font-disp);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.formula-result .pct { font-size: 18px; color: rgba(255,255,255,.6); }
.formula-result.nodata {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  font-family: var(--font-sans);
}

/* ─── Action plan ─── */
.plan-list { display: grid; gap: 10px; }
.plan-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 14px;
  align-items: start;
  cursor: pointer;
}
.plan-card:hover { border-color: var(--ink-4); }
.plan-card.high { border-left: 3px solid var(--red); }
.plan-card.medium { border-left: 3px solid var(--amber); }
.plan-card.low { border-left: 3px solid var(--ink-4); }
.plan-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-4);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.plan-title {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.005em;
  margin-bottom: 6px;
}
.plan-why {
  font-size: 13px;
  color: var(--ink-3);
}
.plan-tags {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 8px;
}
.plan-status select {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

/* ─── Report ─── */
.report-page {
  max-width: 940px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 40px 48px;
  box-shadow: var(--shadow-sm);
}
.report-h1 {
  font-family: var(--font-disp);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.report-sub { color: var(--ink-3); font-size: 13.5px; margin-bottom: 28px; }
.report-block { margin-bottom: 32px; }
.report-block h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin: 0 0 10px;
}
.report-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.report-stats .cell {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}
.report-stats .cell:last-child { border-right: 0; }
.report-stats .label { font-size: 11px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.report-stats .value { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; margin-top: 2px; font-variant-numeric: tabular-nums; }

.disclaimer {
  background: var(--amber-soft);
  border: 1px solid #efd9a8;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #6b4b14;
  line-height: 1.5;
}
.disclaimer b { color: #4f3608; }

/* ─── Diagnostics create ─── */
.create-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  align-items: start;
}
.marketplace-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mp-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
}
.mp-card:hover { border-color: var(--ink-4); }
.mp-card.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mp-card .logo {
  width: 40px; height: 40px; border-radius: 9px;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  color: #fff;
}
.mp-card .wb { background: linear-gradient(135deg, #B43FCB, #842FAB); }
.mp-card .oz { background: linear-gradient(135deg, #1E73E8, #0050BD); }
.mp-card h4 { margin: 0 0 2px; font-size: 14px; font-weight: 700; }
.mp-card .meta { font-size: 12px; color: var(--ink-3); }

.field-stack { display: grid; gap: 14px; }
.field-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ─── Mode banner ─── */
.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--blue-soft);
  border: 1px solid #c9dcf5;
  border-radius: 10px;
  padding: 10px 12px;
  color: #1a4f9e;
  font-size: 12.5px;
  margin-bottom: 16px;
}
.banner svg { flex-shrink: 0; margin-top: 2px; }
.banner b { color: #0f3a7a; }
.banner.error {
  background: var(--red-soft);
  border-color: #f2c6ce;
  color: var(--red);
}
.banner.error b { color: var(--red); }

/* ─── Auth ─── */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.74), rgba(244,245,247,.94)),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
}
.auth-title {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.12;
}
.auth-sub {
  margin: 0 0 18px;
  color: var(--ink-3);
  font-size: 13.5px;
  line-height: 1.55;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 10px;
  margin-bottom: 14px;
}
.auth-tabs button {
  height: 34px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
}
.auth-tabs button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(11,18,32,.08);
}
.auth-yandex {
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 14px;
}
.auth-yandex:hover {
  background: var(--surface-soft);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-4);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
  margin: 4px 0 14px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}
.auth-form {
  display: grid;
  gap: 12px;
}
.auth-form label {
  display: grid;
  gap: 6px;
}
.auth-form label span {
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.auth-form input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 12px;
  background: var(--surface);
  outline: none;
}
.auth-form input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11,18,32,.08);
}
.auth-password-field {
  position: relative;
}
.auth-password-field input {
  width: 100%;
  padding-right: 42px;
}
.auth-password-field button {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--ink-4);
}
.auth-password-field button:hover {
  background: var(--surface-soft);
  color: var(--ink);
}
.auth-password-field svg {
  width: 16px;
  height: 16px;
}
.auth-form .btn {
  justify-content: center;
  margin-top: 4px;
}
.auth-error {
  margin-top: 12px;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #f2c6ce;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.45;
}
.auth-note {
  margin-top: 14px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.5;
}
.save-state {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--green);
}
.save-state.dirty {
  color: var(--amber);
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
  max-width: 220px;
}
.user-menu span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu button {
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

/* misc */
.row { display: flex; align-items: center; gap: 8px; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr { position: absolute; left: -9999px; }

/* ─── Audits table ─── */
.audits-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: visible;
  position: relative;
}
.audits-h, .audits-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1.6fr) 78px 150px 92px 80px 80px 110px minmax(0, 1fr) 140px;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  font-size: 13px;
}
.audits-h {
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  border-radius: calc(var(--r-md) - 1px) calc(var(--r-md) - 1px) 0 0;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.audits-h .num, .audits-row .num { text-align: right; }
.audits-row {
  border-bottom: 1px solid var(--line-soft);
  position: relative;
  z-index: 1;
  cursor: pointer;
}
.audits-row.menu-open { z-index: 120; }
.audits-row:last-child { border-bottom: 0; }
.audits-row:hover { background: var(--surface-soft); }
.audits-row.current {
  background: linear-gradient(90deg, var(--accent-soft) 0%, transparent 40%);
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}
.audits-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.audits-name > span:first-child {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audits-cat {
  font-size: 11.5px;
  color: var(--ink-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audits-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}
.audits-actions { display: flex; justify-content: flex-end; gap: 6px; position: relative; z-index: 90; }
.row-menu-btn { padding: 0; width: 30px; justify-content: center; }
.row-menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
}
.row-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 130;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
}
.row-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  text-align: left;
  width: 100%;
  white-space: nowrap;
}
.row-menu-item:hover { background: var(--surface-soft); color: var(--ink); }
.row-menu-item.danger { color: var(--red); }
.row-menu-item.danger:hover { background: var(--red-soft); }
.row-menu-sep { height: 1px; background: var(--line-soft); margin: 4px 0; }

.mp-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}
.mp-pill.wb { background: linear-gradient(135deg, #B43FCB, #842FAB); }
.mp-pill.ozon { background: linear-gradient(135deg, #1E73E8, #0050BD); }

/* ─── History list ─── */
.hist-list {
  padding: 8px 0;
  max-height: 560px;
  overflow: auto;
}
.hist-event {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding: 10px 18px;
  position: relative;
}
.hist-event::before {
  content: "";
  position: absolute;
  left: 28px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}
.hist-event:first-child::before { top: 14px; }
.hist-event:last-child::before { bottom: calc(100% - 18px); }
.hist-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  margin-top: 4px;
  margin-left: 6px;
  z-index: 1;
  position: relative;
}
.hist-event-h {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.hist-when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  white-space: nowrap;
}
.hist-who { font-size: 11.5px; color: var(--ink-3); font-weight: 500; white-space: nowrap; }
.hist-event-what {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.45;
}
.hist-event-detail {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* dynamics rows */
.dyn-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 14px;
  padding: 10px 20px;
  border-top: 1px solid var(--line-soft);
  align-items: flex-start;
}
