/* КонтентФерма Performance — фирменный стиль: Manrope, #004643 / #003940, коралл #ff5f60 */
:root {
  color-scheme: light;
  --kf-green: #004643;
  --kf-green-deep: #003940;
  --kf-coral: #ff5f60;
  --kf-coral-ink: #d93f40;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --line: #e2e8e6;
  --line-strong: #cdd7d4;
  --ink: #0f2624;
  --ink-2: #4b5f5c;
  --ink-3: #7f918e;
  --accent: var(--kf-green);
  --accent-soft: #e3efed;
  --chart-1: #0b6b66;
  --chart-2: #ff5f60;
  --chart-3: #c98a00;
  --chart-grid: #e8eeec;
  --good: #1a8f4c;
  --good-soft: #e3f4ea;
  --warn: #b97700;
  --warn-soft: #fff3d9;
  --bad: #d93f40;
  --bad-soft: #ffe8e8;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0, 40, 38, .05), 0 8px 24px rgba(0, 40, 38, .06);
  --sidebar: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1716;
    --surface: #152321;
    --surface-2: #1b2c2a;
    --line: #263a37;
    --line-strong: #345050;
    --ink: #eef5f3;
    --ink-2: #b4c6c2;
    --ink-3: #829591;
    --accent: #5fc4b8;
    --accent-soft: #1d3b37;
    --chart-1: #4fb8ad;
    --chart-2: #ff7676;
    --chart-3: #e2a72e;
    --chart-grid: #22332f;
    --good: #4cc483;
    --good-soft: #173527;
    --warn: #e2a72e;
    --warn-soft: #3a2e12;
    --bad: #ff7676;
    --bad-soft: #3d1d1e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--kf-green);
  color: #fff;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--kf-coral); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none;
}
.brand-name { font-weight: 800; font-size: 15px; line-height: 1.15; }
.brand-name small { display: block; font-weight: 600; font-size: 12px; opacity: .7; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 999px;
  color: rgba(255, 255, 255, .82); text-decoration: none; font-weight: 600; cursor: pointer;
  border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, .14); color: #fff; }
.nav-item .count { margin-left: auto; background: var(--kf-coral); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 16px 12px 6px; font-weight: 700; }
.nav-project { font-size: 13px; padding: 7px 12px; }
.nav-project .dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .45); flex: none; }
.nav-project .dot.bad { background: var(--kf-coral); }
.sidebar-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 13px; }
.sidebar-foot .who { font-weight: 700; }
.sidebar-foot button { background: none; border: 0; color: rgba(255, 255, 255, .7); padding: 0; cursor: pointer; text-decoration: underline; font-size: 12px; }
.ico { width: 18px; height: 18px; flex: none; }

.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { text-decoration: none; color: var(--ink-2); }
.crumbs a:hover { color: var(--accent); }

.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.mt { margin-top: 16px; }
.mt-l { margin-top: 28px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .hint { font-size: 12px; color: var(--ink-3); }

/* ---------- KPI tiles ---------- */
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--kf-green), var(--kf-coral)); opacity: .85; }
.kpi .label { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 28px; font-weight: 800; margin: 6px 0 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .value small { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.kpi .foot { font-size: 12.5px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.delta { font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--ink-3); }
.bar-track { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin-top: 10px; position: relative; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--chart-1); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--bad); }
.bar-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; border-radius: 1px; }

/* ---------- pills / buttons / chips ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 9px 16px; font-weight: 700; font-size: 13.5px;
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--kf-coral); border-color: var(--kf-coral); color: #fff; box-shadow: 0 6px 16px rgba(255, 95, 96, .28); }
.btn.primary:hover { background: #ff4c4d; }
.btn.green { background: var(--kf-green); border-color: var(--kf-green); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 13px; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg button.active { background: var(--kf-green); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 700; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--kf-coral); }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; color: var(--ink-2); }
.chip .pdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip.good { background: var(--good-soft); border-color: transparent; color: var(--good); }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.svc { font-size: 11px; padding: 2px 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t td.r, .t th.r { text-align: right; font-variant-numeric: tabular-nums; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--surface-2); }
.t .strong { font-weight: 700; }
.t tfoot td { font-weight: 800; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.pname { font-weight: 700; }
.pname small { display: block; font-weight: 500; color: var(--ink-3); font-size: 12px; }
.mini-bar { width: 90px; height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; position: relative; display: inline-block; vertical-align: middle; }
.mini-bar span { position: absolute; inset: 0 auto 0 0; background: var(--chart-1); border-radius: 999px; }
.mini-bar span.warn { background: var(--warn); }
.mini-bar span.bad { background: var(--bad); }

/* ---------- alerts ---------- */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; }
.alert .lvl { font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 8px; flex: none; margin-top: 1px; }
.alert.high .lvl { background: var(--bad-soft); color: var(--bad); }
.alert.mid .lvl { background: var(--warn-soft); color: var(--warn); }
.alert.low .lvl { background: var(--accent-soft); color: var(--accent); }
.alert a { font-weight: 700; text-decoration: none; }
.empty { text-align: center; color: var(--ink-3); padding: 28px 12px; }
.empty .em { font-size: 26px; display: block; margin-bottom: 6px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .ax { fill: var(--ink-3); font-size: 11px; font-family: inherit; }
.chart .grid-l { stroke: var(--chart-grid); stroke-width: 1; }
.chart .base-l { stroke: var(--line-strong); stroke-width: 1; }
.chart .hl { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .ref { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .ref-t { fill: var(--ink-2); font-size: 11px; font-weight: 700; }
.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 10px; padding: 7px 10px; font-size: 12px;
  white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 5; box-shadow: var(--shadow); line-height: 1.4;
}
.tip b { font-weight: 800; }
.chart-title { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.chart-big { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 140px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .nm { display: flex; align-items: center; gap: 7px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .tr { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.hbar .fl { height: 100%; background: var(--chart-1); border-radius: 999px; }
.hbar .vl { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.hbar .vl small { display: block; font-weight: 500; color: var(--ink-3); font-size: 11.5px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- SEO / GEO ---------- */
.pos { display: inline-block; min-width: 34px; text-align: center; font-weight: 800; border-radius: 8px; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.pos.p3 { background: #0b6b66; color: #fff; }
.pos.p10 { background: #6fb7ae; color: #05302d; }
.pos.p30 { background: var(--warn-soft); color: var(--warn); }
.pos.pn { background: var(--surface-2); color: var(--ink-3); }
.spark { width: 90px; height: 26px; display: block; }
.matrix td.cell { text-align: center; }
.mcell { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 28px; border-radius: 8px; font-weight: 800; font-size: 12px; cursor: pointer; border: 1px solid transparent; }
.mcell.yes { background: var(--good-soft); color: var(--good); }
.mcell.cited { background: var(--good); color: #fff; }
.mcell.no { background: var(--surface-2); color: var(--ink-3); border-color: var(--line); }
.mcell.none { background: transparent; color: var(--ink-3); cursor: default; }
.answer { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; font-size: 13px; max-height: 360px; overflow: auto; }
.answer mark { background: #ffe08a; color: #222; border-radius: 3px; padding: 0 2px; }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(185px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.kcol.drop { border-color: var(--accent); background: var(--accent-soft); }
.kcol-head { display: flex; justify-content: space-between; font-weight: 800; font-size: 13px; padding: 2px 4px 6px; }
.kcol-head span { color: var(--ink-3); }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; cursor: grab; font-size: 13px; }
.tcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.tcard .tt { font-weight: 700; margin-bottom: 7px; }
.tcard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-3); }
.tcard.high { border-left: 3px solid var(--kf-coral); }
.overdue { color: var(--bad); font-weight: 700; }
.tlist .t td { padding: 9px 10px; }
.check { width: 18px; height: 18px; border-radius: 6px; border: 2px solid var(--line-strong); display: inline-grid; place-items: center; cursor: pointer; background: var(--surface); }
.check.on { background: var(--good); border-color: var(--good); color: #fff; }

/* ---------- forms / modal ---------- */
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
label.f .help { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.inp, select.inp, textarea.inp {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 12px; padding: 9px 12px; font-size: 14px; font-weight: 500; width: 100%; color: var(--ink);
}
.inp:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea.inp { min-height: 90px; resize: vertical; font-family: inherit; }
.form { display: grid; gap: 14px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.checkline input { width: 16px; height: 16px; accent-color: var(--kf-green); }
.modal-bg { position: fixed; inset: 0; background: rgba(5, 25, 23, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 24px; padding: 24px; width: min(620px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.x { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1; flex: none; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 11px 18px; border-radius: 999px; font-weight: 700; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--bad); color: #fff; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--surface-2); border-radius: 8px; padding: 2px 6px; }
pre.code { padding: 10px 12px; white-space: pre-wrap; margin: 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--kf-green), var(--kf-green-deep)); padding: 16px; }
.login-card { width: min(400px, 100%); }
.login h1 { color: #fff; font-size: 34px; line-height: 1.1; margin: 18px 0 8px; }
.login p { color: rgba(255, 255, 255, .75); margin: 0 0 22px; }
.login .card { border: 0; }
.err-line { color: var(--bad); font-size: 13px; font-weight: 600; }

/* ---------- integrations ---------- */
.integ { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.integ:last-child { border-bottom: 0; }
.integ .logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; }
.integ .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.integ .err { color: var(--bad); font-size: 12.5px; margin-top: 3px; word-break: break-word; }

/* ---------- client cabinet ---------- */
.client-top { background: linear-gradient(135deg, var(--kf-green), var(--kf-green-deep)); color: #fff; padding: 28px 16px 70px; }
.client-top .in, .client-body { max-width: 1180px; margin: 0 auto; }
.client-top h1 { font-size: 30px; margin-top: 14px; }
.client-top .sub { opacity: .75; margin-top: 4px; }
.client-body { padding: 0 16px 60px; margin-top: -48px; }
.client-top .seg { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .15); }
.client-top .seg button { color: rgba(255, 255, 255, .8); }
.client-top .seg button.active { background: #fff; color: var(--kf-green); }

.mobile-bar { display: none; }

@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-21 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--kf-green); color: #fff; position: sticky; top: 0; z-index: 30; }
  .mobile-bar button { background: rgba(255, 255, 255, .12); border: 0; color: #fff; border-radius: 10px; padding: 7px 10px; font-weight: 700; }
  .main { padding: 18px 16px 50px; }
  .g-3, .g-2 { grid-template-columns: minmax(0, 1fr); }
  .form .two, .form .three { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 96px 1fr 84px; }
  h1 { font-size: 22px; }
}
@media (max-width: 520px) {
  .g-4 { grid-template-columns: minmax(0, 1fr); }
  .kpi .value { font-size: 24px; }
}
