/* ============================================================
   Гант: загрузка инженеров по сделкам
   ============================================================ */

:root {
  --bg: #F3F1EC;
  --paper: #FFFFFF;
  --paper-2: #FBFAF6;
  --ink: #151A1F;
  --ink-2: #4C5561;
  --ink-3: #88919C;
  --ink-4: #AAB2BB;
  --line: #E5E1D8;
  --line-2: #F0EDE6;
  --accent: #B04A2A;
  --accent-soft: #F7E7DF;
  --ok: #3F7A58;
  --radius: 14px;
  --left-w: 304px;
  --row-group: 36px;
  --row-lane: 24px;
  --shadow: 0 1px 2px rgba(21, 26, 31, .04), 0 12px 32px -24px rgba(21, 26, 31, .35);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "tnum" 1, "cv05" 1;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

svg { width: 16px; height: 16px; flex: 0 0 auto; }

/* ---------------- шапка ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1620px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--ink); color: #F6F2E9; flex: 0 0 auto; overflow: hidden; }
.brand-mark svg { width: 20px; height: 20px; }

.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 18px;
  font-weight: 640;
  letter-spacing: -.015em;
  line-height: 1.2;
}
.brand-text p {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-demo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  background: #FBF0E3;
  border: 1px solid #F0DCC6;
  color: #8A5A22;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-demo .dot { width: 5px; height: 5px; border-radius: 50%; background: #C9822F; }

.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.seg {
  display: inline-flex;
  padding: 3px;
  background: #EFEDE7;
  border-radius: 10px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 550;
  padding: 5px 11px;
  border-radius: 7px;
  transition: background .14s, color .14s, box-shadow .14s;
}
.seg button:hover { color: var(--ink); }
.seg button.is-on {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(21, 26, 31, .12);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
  transition: background .14s, border-color .14s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: #FCFBF7; border-color: #D9D4C9; }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 15px; height: 15px; color: var(--ink-2); }
.btn.icon-only { width: 34px; padding: 0; justify-content: center; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #232B33; border-color: #232B33; }
.btn.ghost { background: transparent; }
.btn.file { position: relative; overflow: hidden; }

/* ---------------- страница ---------------- */

.page {
  max-width: 1620px;
  margin: 0 auto;
  padding: 18px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------------- KPI ---------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px 12px;
  min-width: 0;
}
.kpi-label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value {
  margin-top: 5px;
  font-size: 25px;
  font-weight: 620;
  letter-spacing: -.025em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.kpi-sub {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi.is-alert { border-color: #EBD3C7; background: linear-gradient(180deg, #FFFCFA, #FFF8F4); }
.kpi.is-alert .kpi-value { color: var(--accent); }
.kpi.is-good .kpi-value { color: var(--ok); }

/* ---------------- фильтры ---------------- */

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

.f-label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.chips { display: flex; flex-wrap: wrap; gap: 4px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: #F4F2EC;
  color: var(--ink-2);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.2;
  transition: background .14s, color .14s, opacity .14s;
}
.chip i { width: 7px; height: 7px; border-radius: 2px; background: currentColor; opacity: .8; }
.chip:hover { background: #EDEAE2; }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.is-on i { background: #fff; opacity: .95; }
.chip.is-off { opacity: .45; }

.f-sep { width: 1px; height: 22px; background: var(--line); }

.field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-2);
  transition: border-color .14s, box-shadow .14s;
}
.field:focus-within { border-color: #BFC6CE; box-shadow: 0 0 0 3px rgba(21, 26, 31, .05); }
.field svg { width: 14px; height: 14px; color: var(--ink-4); }
.field input {
  border: 0; outline: 0; background: transparent;
  font-size: 13px; width: 210px; color: var(--ink);
}
.field input::placeholder { color: var(--ink-4); }
.field.select { padding: 0 6px 0 0; }
.field select {
  border: 0; outline: 0; background: transparent;
  font-size: 13px; font-weight: 500; color: var(--ink);
  height: 30px; padding: 0 8px; max-width: 230px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2388919C' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 22px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  margin-left: auto;
  white-space: nowrap;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 30px; height: 18px; border-radius: 999px;
  background: #DCD8CE; position: relative; transition: background .16s;
  flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .16s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(176, 74, 42, .22); }

/* ---------------- рабочая область ---------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: 14px;
  align-items: start;
}

.chart-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}

.chart-scroll {
  overflow: auto;
  max-height: calc(100vh - 320px);
  min-height: 320px;
  position: relative;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #CFCABF transparent;
}
.chart-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.chart-scroll::-webkit-scrollbar-thumb {
  background: #D6D1C6; border-radius: 99px; border: 3px solid var(--paper);
}
.chart-scroll::-webkit-scrollbar-thumb:hover { background: #C2BCAF; }

.chart-inner { width: max-content; min-width: 100%; }

/* --- шапка шкалы --- */

.head {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 30;
  height: 54px;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.head-left {
  position: sticky;
  left: 0;
  z-index: 31;
  width: var(--left-w);
  flex: 0 0 var(--left-w);
  display: flex;
  align-items: flex-end;
  padding: 0 14px 9px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.head-track { position: relative; height: 54px; flex: 0 0 auto; }

.months { position: absolute; inset: 0 0 auto 0; height: 28px; }
.m-cell {
  position: absolute; top: 0; height: 28px;
  display: flex; align-items: center;
  padding-left: 8px;
  font-size: 11.5px; font-weight: 620;
  letter-spacing: .01em;
  color: var(--ink-2);
  border-left: 1px solid var(--line);
  white-space: nowrap; overflow: hidden;
  background: linear-gradient(180deg, #FFFDF9, #FBF9F4);
}

.ticks { position: absolute; left: 0; right: 0; top: 28px; height: 26px; }

.d-cell {
  position: absolute; top: 0; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; color: var(--ink-3);
  border-left: 1px solid var(--line-2);
  font-variant-numeric: tabular-nums;
}
.d-cell.we { background: #FAF8F2; color: #B0A99C; }
.d-cell.hol { background: #FBF2E7; color: #B4885B; }
.d-cell.now { color: var(--accent); font-weight: 700; }

.w-cell {
  position: absolute; top: 0; height: 26px;
  display: flex; align-items: center;
  padding-left: 6px;
  font-size: 10.5px; color: var(--ink-3);
  border-left: 1px solid var(--line-2);
  white-space: nowrap; overflow: hidden;
}
.w-cell b { font-weight: 600; color: var(--ink-2); margin-right: 4px; }

.today-flag {
  position: absolute; top: 0; height: 54px; width: 2px;
  background: var(--accent);
  z-index: 3;
  pointer-events: none;
}
.today-flag::before {
  content: ""; position: absolute; top: 0; left: -4px;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--accent);
}

/* --- тело --- */

.body { position: relative; }

.bg { position: absolute; top: 0; bottom: 0; z-index: 0; pointer-events: none; }
.bg .we { position: absolute; top: 0; bottom: 0; background: #FAF8F2; }
.bg .hol {
  position: absolute; top: 0; bottom: 0;
  background: repeating-linear-gradient(135deg, #FBF2E7 0 7px, #F8ECDD 7px 14px);
}
.bg .ml { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.bg .today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .8; }

.rows { position: relative; z-index: 1; }

.row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line-2);
}
.row-group { height: var(--row-group); background: var(--paper-2); border-bottom-color: var(--line); }
.row-lane { height: var(--row-lane); }
.row-lane:last-child { border-bottom: none; }
.row.flash .cell-left { animation: flash 1.1s ease-out; }
@keyframes flash {
  0% { background: #FBE9DF; }
  100% { background: var(--paper); }
}

.cell-left {
  position: sticky;
  left: 0;
  z-index: 5;
  width: var(--left-w);
  flex: 0 0 var(--left-w);
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 12px;
  min-width: 0;
}
.row-group .cell-left { background: var(--paper-2); }

.eng { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; }

.avatar {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  flex: 0 0 auto;
  background: #EDEAE1;
  color: #5B6470;
}

.eng-meta { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; }
.eng-meta b {
  font-size: 13px; font-weight: 600; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eng-meta span {
  font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.eng-load { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: 0 0 auto; margin-left: 6px; }
.eng-load b { font-size: 12px; font-weight: 650; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.eng-load i { font-style: normal; font-size: 10px; color: var(--ink-4); }
.eng-load.hot b { color: var(--accent); }
.eng-load.cold b { color: var(--ink-3); }

.track { position: relative; flex: 0 0 auto; }

/* полоса загрузки в шапке инженера */
.heat {
  position: absolute; left: 0; right: 0; top: 0; height: 10px;
  background: #FBFAF6;
  border-bottom: 1px solid #F3F0E8;
}
.heat i {
  position: absolute; top: 0; height: 9px;
  border-right: 1px solid rgba(255, 255, 255, .55);
}
.heat i.z { background: #EFECE4; }
.heat i.q1 { background: #DDEBE1; }
.heat i.q2 { background: #B4D2BE; }
.heat i.q3 { background: #6E9E80; }
.heat i.ov { background: linear-gradient(180deg, #CB5E3E, #B04A2A); }

/* --- полосы --- */

.bar {
  position: absolute;
  top: 2px;
  height: 18px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  color: #fff;
  font-size: 10.5px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .07);
  transition: filter .12s, box-shadow .12s, opacity .16s;
  z-index: 2;
}
.bar:hover { filter: brightness(1.07) saturate(1.05); z-index: 3; }
.bar-stage {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 2px 3px 1px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .24);
  text-transform: uppercase;
}
.bar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bar.small .bar-name { display: none; }
.bar.tiny { padding: 0 2px; }
.bar.tiny .bar-stage { display: none; }

.bar.is-selected {
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink);
  z-index: 4;
}
.dim-mode .bar { opacity: .3; }
.dim-mode .bar.is-selected, .dim-mode .bar.is-related { opacity: 1; }

/* ---------------- подвал графика ---------------- */

.chart-foot {
  border-top: 1px solid var(--line);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--paper);
}
.legend { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.lg-item { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-3); }
.lg-bar { width: 18px; height: 9px; border-radius: 3px; background: linear-gradient(90deg, #3D6B8E 0 50%, #8E6A4E 50% 100%); }
.lg-today { width: 2px; height: 12px; background: var(--accent); }
.lg-heat { width: 10px; height: 9px; border-radius: 2px; background: #B4D2BE; }
.heat-scale { display: inline-flex; gap: 2px; }
.heat-scale i { width: 12px; height: 9px; border-radius: 2px; display: block; }
.heat-scale .h0 { background: #EFECE4; }
.heat-scale .h1 { background: #DDEBE1; }
.heat-scale .h2 { background: #B4D2BE; }
.heat-scale .h3 { background: #6E9E80; }
.heat-scale .h4 { background: #B04A2A; }
.heat-cap { font-size: 10.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.foot-note { font-size: 11.5px; color: var(--ink-4); }

/* ---------------- боковая панель ---------------- */

.side {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
}
.panel-title {
  font-size: 10.5px; font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
.panel-count {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  background: #F2F0EA; border-radius: 6px; padding: 1px 6px;
}

.empty {
  font-size: 12.5px; color: var(--ink-3); line-height: 1.5;
  padding: 6px 0 2px;
}

/* выбранная задача */
.sel-deal {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 620; letter-spacing: -.01em;
  margin-bottom: 3px;
}
.sel-deal i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.sel-stage { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 12.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; text-align: right; }

.sel-note {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2);
  font-size: 12.5px; color: var(--ink-2); line-height: 1.45;
}

.sel-actions { display: flex; gap: 6px; margin-top: 11px; }
.sel-actions .btn { height: 30px; font-size: 12px; padding: 0 10px; }

/* конфликты */
.conf-list { display: flex; flex-direction: column; gap: 2px; }

.conf {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  border: 0; background: transparent;
  padding: 7px 6px; border-radius: 8px;
  text-align: left;
  transition: background .13s;
}
.conf:hover { background: #FBF3EE; }
.conf .bar-mark {
  width: 3px; height: 26px; border-radius: 2px;
  background: var(--accent); flex: 0 0 auto; opacity: .75;
}
.conf .conf-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.conf b { font-size: 12.5px; font-weight: 600; }
.conf em {
  font-style: normal; font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conf .conf-pct {
  font-size: 11.5px; font-weight: 650; color: var(--accent);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.conf-all {
  margin-top: 8px; width: 100%; height: 28px;
  font-size: 12px;
}

/* ---------------- подпись ---------------- */

.signature {
  font-size: 11.5px;
  color: var(--ink-4);
  padding: 2px 2px 0;
}

/* ---------------- тултип ---------------- */

.tip {
  position: fixed;
  z-index: 100;
  max-width: 290px;
  background: rgba(21, 26, 31, .96);
  color: #fff;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .55);
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .1s, transform .1s;
}
.tip.is-on { opacity: 1; transform: none; }
.tip .t-deal { font-weight: 650; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.tip .t-deal i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.tip .t-meta { color: #B9C2CB; margin-top: 2px; }
.tip .t-dates { margin-top: 6px; font-variant-numeric: tabular-nums; }
.tip .t-note { margin-top: 6px; color: #D6DCE2; border-top: 1px solid rgba(255,255,255,.14); padding-top: 6px; }

/* ---------------- диалог ---------------- */

.dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(680px, calc(100vw - 32px));
  background: var(--paper);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .5);
  color: var(--ink);
}
.dialog::backdrop { background: rgba(21, 26, 31, .42); backdrop-filter: blur(2px); }

.dlg { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dlg-head h2 { font-size: 17px; font-weight: 640; letter-spacing: -.01em; }
.dlg-head p { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.x {
  border: 0; background: #F2F0EA; color: var(--ink-2);
  width: 28px; height: 28px; border-radius: 8px;
  font-size: 18px; line-height: 1; flex: 0 0 auto;
}
.x:hover { background: #E9E6DE; }

.dlg-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.dlg-label { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

#importText {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: 12px/1.5 var(--mono);
  background: #FCFBF7;
  outline: 0;
}
#importText:focus { border-color: #BFC6CE; box-shadow: 0 0 0 3px rgba(21, 26, 31, .05); }

.err {
  margin: 0;
  font-size: 12px;
  color: #9C2F13;
  background: #FBEAE3;
  border: 1px solid #F3D3C6;
  border-radius: 8px;
  padding: 7px 10px;
}
.dlg-foot { display: flex; justify-content: space-between; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 10px);
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 9px;
  z-index: 200;
  opacity: 0;
  transition: opacity .18s, transform .18s;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- адаптив ---------------- */

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .side .panel { flex: 1 1 300px; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar-inner { padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .page { padding: 12px 12px 30px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { gap: 8px; }
  .switch { margin-left: 0; width: 100%; }
  .field input { width: 100%; }
  .field.search { flex: 1 1 100%; }
  .field.select select { max-width: none; width: 100%; }
  .chart-scroll { max-height: 70vh; }
  :root { --left-w: 196px; }
  .brand-text h1 { font-size: 16px; }
}

@media print {
  @page { size: A3 landscape; margin: 8mm; }
  body { background: #fff; }
  .topbar { position: static; border-bottom: 1px solid #ddd; }
  .tools, .filters, .side, .signature, .badge-demo, .chart-foot .foot-note { display: none !important; }
  .page { padding: 0; }
  .kpis { display: none; }
  .chart-scroll { max-height: none; overflow: visible; }
  .chart-card { overflow: visible; }
  .chart-inner { zoom: 1; }
  .head { position: static; }
  .cell-left { position: static; }
  .chart-card { border: 0; box-shadow: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------------- пустое состояние ---------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--ink-3);
  font-size: 13px;
}
.empty-state p { margin: 0; }

/* компактный режим в обзоре */
.chart-inner.xs .bar-name { display: none; }
.chart-inner.xs .bar { justify-content: center; padding: 0 2px; }

.bar-code { display: none; font-size: 9.5px; font-weight: 700; letter-spacing: .02em; opacity: .95; }
.chart-inner.xs .bar-code { display: inline; }
.chart-inner.xs .bar.narrow .bar-code { display: none; }
.chart-inner.xs .heat i { border-right: 0; }
.chart-inner.xs .eng-load i { color: var(--ink-4); }

.w-cell.bare { border-left: 1px solid #F4F1EA; }

/* сделки в боковой панели */
.deal-list { display: flex; flex-direction: column; gap: 1px; margin: 0 -4px; }
.deal-row {
  display: flex; align-items: center; gap: 7px;
  width: 100%; border: 0; background: transparent;
  padding: 5px 4px; border-radius: 7px; text-align: left;
  font-size: 12px;
  transition: background .13s;
}
.deal-row:hover { background: #F7F5F0; }
.deal-dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.deal-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.deal-bar { flex: 0 0 46px; height: 4px; border-radius: 99px; background: #F0EDE6; overflow: hidden; }
.deal-bar i { display: block; height: 100%; border-radius: 99px; opacity: .8; }
.deal-val { flex: 0 0 26px; text-align: right; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.filters .btn { height: 30px; font-size: 12px; padding: 0 10px; }

/* ============================================================
   Вход, роли, формы, настройки (v2)
   ============================================================ */

/* ---------- вход ---------- */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 620px at 50% -12%, #FBF7EE 0%, rgba(251, 247, 238, 0) 70%),
    var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 26px;
  box-shadow: 0 40px 90px -60px rgba(21, 26, 31, .55);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.login-sub { font-size: 12.5px; color: var(--ink-3); margin: -6px 0 6px; }
.login-hint { font-size: 11.5px; color: var(--ink-4); text-align: center; margin-top: 2px; }
.login-hint b { color: var(--ink-3); font-weight: 600; }

.brand-mark.big {
  width: 46px; height: 46px; border-radius: 13px;
  margin-bottom: 4px;
}
.brand-mark.big svg { width: 24px; height: 24px; }

.btn.wide { width: 100%; justify-content: center; height: 40px; font-size: 14px; }

/* ---------- пользователь в шапке ---------- */

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  margin-right: 2px;
  max-width: 170px;
}
.user-chip b {
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.user-chip em {
  font-style: normal; font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .07em;
}
.user-chip em.role-admin { color: var(--ok); }

/* ---------- выпадающий фильтр этапов ---------- */

.dropdown { position: relative; }

.drop-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 60px -24px rgba(21, 26, 31, .4);
  padding: 7px;
  min-width: 260px;
}

.drop-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.drop-item:hover { background: #F7F5F0; }
.drop-item input { accent-color: var(--ink); width: 14px; height: 14px; }
.drop-item i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }

.drop-foot {
  display: flex; gap: 6px;
  padding: 7px 4px 2px;
  margin-top: 5px;
  border-top: 1px solid var(--line-2);
}
.drop-foot button {
  flex: 1; height: 28px; font-size: 11.5px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink-2);
}
.drop-foot button:hover { background: #FBFAF6; }

.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  background: #F1EEE7;
  color: var(--ink-2);
  margin: 0 2px;
}

/* ---------- формы ---------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.fld {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.fld > span {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fld input,
.fld select {
  height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  padding: 0 10px;
  font-size: 13.5px;
  color: var(--ink);
  outline: 0;
  min-width: 0;
}
.fld select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2388919C' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.fld input:focus,
.fld select:focus {
  border-color: #BFC6CE;
  box-shadow: 0 0 0 3px rgba(21, 26, 31, .06);
}
.fld input:disabled,
.fld select:disabled { background: #F7F5F0; color: var(--ink-3); }
.fld .hint {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-3);
  min-height: 13px;
  line-height: 1.3;
}
.fld .hint.is-warn { color: var(--accent); }
.span2 { grid-column: span 2; }

.days-hint {
  display: flex;
  align-items: center;
  height: 36px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.newdeal {
  background: #FBFAF6;
  border: 1px dashed var(--line);
  border-radius: 11px;
  padding: 11px;
}

.warn {
  font-size: 12.5px;
  line-height: 1.45;
  padding: 9px 11px;
  border-radius: 9px;
  background: #FDF1E9;
  border: 1px solid #F3D6C6;
  color: #8B3E1F;
}
.warn b { color: #6E2F14; }

.btn.danger { color: #9C2F13; border-color: #EBD3C7; background: #FFF8F4; }
.btn.danger:hover { background: #FDEDE6; border-color: #E4C3B4; }

.spacer { flex: 1 1 auto; }

/* ---------- диалоги ---------- */

.dialog.wide { width: min(920px, calc(100vw - 32px)); }
.dialog.narrow { width: min(420px, calc(100vw - 32px)); }

.tabs {
  display: flex;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tabs button {
  border: 0;
  background: transparent;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
}
.tabs button:hover { background: #F6F4EE; }
.tabs button.is-on { background: var(--ink); color: #fff; }

.tab-body {
  max-height: min(62vh, 560px);
  overflow: auto;
  padding: 2px 2px 2px 0;
}

/* ---------- настройки ---------- */

.set-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.set-note { font-size: 12px; color: var(--ink-3); }

.set-list { display: flex; flex-direction: column; gap: 7px; }

.set-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #fff;
}
.set-row:hover { border-color: var(--line); }
.set-row .grow { flex: 1 1 170px; min-width: 130px; }
.set-row .sm { flex: 0 0 108px; }
.set-row input,
.set-row select {
  height: 32px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}
.set-row input:focus,
.set-row select:focus { border-color: #BFC6CE; box-shadow: 0 0 0 3px rgba(21, 26, 31, .05); }
.set-row input[type="color"] {
  width: 34px;
  flex: 0 0 34px;
  padding: 2px;
  cursor: pointer;
}
.set-row .cap { flex: 0 0 78px; }

.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 100%;
  margin-top: 2px;
}
.skill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 7px;
  background: #F4F2EC;
  border: 1px solid transparent;
  color: var(--ink-3);
  cursor: pointer;
  user-select: none;
  transition: background .12s, color .12s, border-color .12s;
}
.skill:hover { background: #EDEAE2; }
.skill input { display: none; }
.skill.on { background: #EAF1EC; border-color: #D2E2D8; color: #2F5F45; }
.skill.on::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: #3F7A58;
}

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-3);
  flex: 0 0 auto;
}
.icon-btn:hover { color: #9C2F13; border-color: #EBD3C7; background: #FFF8F4; }
.icon-btn svg { width: 14px; height: 14px; }

.row-note { font-size: 11px; color: var(--ink-4); flex: 0 0 auto; }
.row-warn { font-size: 11px; color: var(--accent); flex: 0 0 auto; }

/* ---------- адаптив (v2) ---------- */

@media (max-width: 1180px) {
  .topbar-inner { gap: 12px; }
  .user-chip { display: none; }
}

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .dialog.wide { width: calc(100vw - 16px); }
  .follow { width: 100%; }
  .drop-panel { min-width: 230px; }
  .tabs button { padding: 6px 9px; font-size: 12.5px; }
  .set-row .grow { flex: 1 1 100%; }
  .set-row .sm { flex: 1 1 40%; }
  .eng-meta span { display: none; }
  .eng-load i { display: none; }
}

@media (max-width: 480px) {
  :root { --left-w: 168px; }
  .avatar { width: 26px; height: 26px; border-radius: 8px; font-size: 10px; }
  .eng { gap: 7px; }
  .eng-meta b { font-size: 12px; }
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink-3);
  font-size: 13px;
}

.warn.ok { background: #F1F7F2; border-color: #D6E6DA; color: #2F5F45; }

.avatar.deal-avatar { font-size: 0; }
.avatar.deal-avatar::after {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, .85);
}

.toast.error { background: #8E2F14; }
.seg-zoom button { font-size: 12px; padding: 4px 9px; }
.filters .seg { flex: 0 0 auto; }

.set-row select.sm { flex: 0 0 138px; }
.set-row input.sm { flex: 0 0 118px; }

/* ---------- синхронизация с Google Таблицей ---------- */

.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #D6E6DA;
  background: #F1F7F2;
  color: #2F5F45;
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}
.sync-chip::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: #3F7A58;
}
.sync-chip.is-error { border-color: #F3D6C6; background: #FDF1E9; color: #8B3E1F; }
.sync-chip.is-error::before { background: var(--accent); }
.sync-chip.is-idle { border-color: var(--line); background: #F7F5F0; color: var(--ink-3); }
.sync-chip.is-idle::before { background: var(--ink-4); }

.sync-box {
  border: 1px solid var(--line-2);
  border-radius: 11px;
  padding: 11px;
  background: #FBFAF6;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.sync-box .set-row { background: #fff; }
.sync-hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }
.sync-hint b { color: var(--ink-2); }
.sync-err { font-size: 11.5px; color: #8B3E1F; }
.sync-ok { font-size: 11.5px; color: #2F5F45; }

/* ---------- дедлайн и факт ---------- */

.form-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 -2px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.form-section::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line-2);
}

.deadline-flag {
  position: absolute;
  top: 0;
  bottom: 2px;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
  z-index: 3;
  pointer-events: none;
  opacity: .9;
}
.deadline-flag::before {
  content: "";
  position: absolute;
  top: 0;
  left: -3px;
  width: 8px;
  height: 7px;
  border-radius: 2px;
  background: inherit;
}
.deadline-flag.is-overdue { opacity: 1; }
.deadline-flag.is-late { opacity: .9; }

.fact-bar {
  position: absolute;
  bottom: 0;
  height: 2px;
  border-radius: 1px;
  background: #94B7A1;
  z-index: 3;
  pointer-events: none;
}
.fact-bar.is-late { background: #C08A3E; }

.days-hint.is-warn { color: var(--accent); font-weight: 500; }

.lg-deadline {
  width: 2px; height: 12px; background: var(--accent); position: relative; border-radius: 1px;
}
.lg-deadline::before {
  content: ""; position: absolute; top: -2px; left: -2px;
  width: 6px; height: 5px; border-radius: 1px; background: inherit;
}
.lg-fact { width: 16px; height: 2px; border-radius: 1px; background: #94B7A1; }

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

/* ---------- разделы ---------- */

.dept-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin: -2px 0 -2px;
}
.dept-tabs button {
  position: relative;
  border: 0;
  background: transparent;
  padding: 9px 14px 10px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-3);
  border-radius: 8px 8px 0 0;
}
.dept-tabs button:hover { color: var(--ink); background: #FBFAF6; }
.dept-tabs button.is-on { color: var(--ink); }
.dept-tabs button.is-on::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

.skill-group {
  flex: 1 1 100%;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-top: 2px;
}

.dept-checks { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.dept-check {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 4px 7px; border-radius: 6px;
  background: #F4F2EC; color: var(--ink-3); cursor: pointer; user-select: none;
}
.dept-check input { display: none; }
.dept-check:has(input:checked) { background: #EAF1EC; color: #2F5F45; }

.mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.mini input {
  height: 28px;
  width: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 7px;
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0;
  background: #fff;
}
.mini input:focus { border-color: #BFC6CE; box-shadow: 0 0 0 3px rgba(21, 26, 31, .05); outline: none; }
.mini-num { width: 66px; }
.mini-text { width: 190px; }
.mini-wide { width: 320px; }


.sel-history { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.hist-title {
  font-size: 10px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-4); margin-bottom: 6px;
}
.hist-row { margin-bottom: 7px; }
.hist-line { font-size: 12px; color: var(--ink-2); }
.hist-line b { color: var(--ink); font-weight: 600; }
.hist-meta { font-size: 10.5px; color: var(--ink-4); margin-top: 1px; }

.tg-on { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-3); }
.tg-actions { border: 0; padding: 0; gap: 8px; }

/* ---------- управленческий учёт ---------- */

.accounting { padding: 2px 0 28px; }
.acc-head h2 { font-size: 18px; font-weight: 650; letter-spacing: -.015em; margin: 0 0 4px; }
.acc-head p { margin: 0 0 14px; color: var(--ink-3); font-size: 13px; max-width: 760px; }
.acc-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 10px; }
.acc-card { background: var(--paper); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; }
.acc-card b { display: block; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.acc-card span { font-size: 11px; color: var(--ink-3); }
.acc-days { font-size: 11.5px; color: var(--ink-3); margin: 0 0 12px 2px; }
.acc-table-wrap { background: var(--paper); border: 1px solid var(--line-2); border-radius: 12px; overflow: auto; }
.acc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.acc-table th {
  text-align: left; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-4); padding: 10px 12px; border-bottom: 1px solid var(--line-2); font-weight: 650;
}
.acc-table td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); }
.acc-table tr:last-child td { border-bottom: 0; }
.acc-table .num { text-align: right; white-space: nowrap; }
.acc-table tr.is-done td { color: var(--ink-3); }
.acc-table td.warn { color: var(--accent); font-weight: 600; }
.acc-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: #EAF1EC; color: #2F5F45; }
.acc-badge.done { background: #F0EEE8; color: var(--ink-3); }
.acc-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
@media (max-width: 900px) { .acc-cards { grid-template-columns: repeat(2, 1fr); } }

.acc-bank {
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 14px 16px; margin: 0 0 12px;
}
.acc-bank-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.acc-bank-head h3 { margin: 0; font-size: 13px; font-weight: 650; }
.acc-bank-head span { font-size: 11px; color: var(--ink-4); }
.acc-bank-total { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 2px; }
.acc-bank-sub { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.acc-bank-more summary { cursor: pointer; font-size: 12px; color: var(--ink-3); }
.acc-bank-more table { margin-top: 8px; }
.acc-bank-note { font-size: 12px; color: var(--ink-3); margin: 0; }

.acc-bank-fx summary { color: #8A6D3B; }
.acc-bank-more + .acc-bank-more { margin-top: 4px; }

/* ---------- сделки: выбор и карточка ---------- */

.deals-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.deals-layout.one { grid-template-columns: 1fr; }
.deals-side { position: sticky; top: 12px; }
.acc-table tbody tr[data-deal-row] { cursor: pointer; }
.acc-table tbody tr[data-deal-row]:hover td { background: #FBFAF6; }
.acc-table tbody tr.is-sel td { background: #FBF7EE; }
.deal-days { font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }
.deal-tasks-title {
  font-size: 10px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-4); margin: 10px 0 2px;
}
.deal-tasks { max-height: 240px; overflow: auto; margin-bottom: 10px; }
.deal-task { padding: 5px 0; border-bottom: 1px solid var(--line-2); }
.deal-task:last-child { border-bottom: 0; }
.deal-task-line { font-size: 12px; color: var(--ink-2); }
.deal-task-line b { font-weight: 600; color: var(--ink); margin-right: 4px; }
.deal-task-meta { font-size: 10.5px; color: var(--ink-4); }
.deal-tag { font-size: 9.5px; padding: 1px 4px; border-radius: 3px; margin-left: 4px; background: #F0EEE8; color: var(--ink-3); }
.deal-tag.done { background: #EAF1EC; color: #2F5F45; }
.deal-tag.late { background: #FBE9DF; color: var(--accent); }
.is-warn { color: var(--accent); font-weight: 600; }
@media (max-width: 1100px) {
  .deals-layout { grid-template-columns: 1fr; }
  .deals-side { position: static; }
}

.task-status {
  display: inline-block; margin-left: 6px; font-size: 9.5px; font-weight: 650;
  letter-spacing: .04em; text-transform: uppercase; padding: 2px 5px; border-radius: 4px;
  background: #F0EEE8; color: var(--ink-3); vertical-align: 1px;
}
.task-status.is-done { background: #EAF1EC; color: #2F5F45; }
.row-group[data-kind="deal"] { cursor: pointer; }
.row-group[data-kind="deal"]:hover { background: #FBFAF6; }

.side-deal-block { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2); }

.task-status.active { background: #F0EEE8; color: var(--ink-3); }
.task-status.work { background: #EAF0F6; color: #3D5A80; }
.task-status.done { background: #EAF1EC; color: #2F5F45; }
.deal-tag.work { background: #EAF0F6; color: #3D5A80; }
.deal-tag.active { background: #F0EEE8; color: var(--ink-3); }

/* ---------- диаграмма по сделке ---------- */

.deal-gantt-block { margin-top: 16px; }
.deal-gantt {
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 12px;
  overflow: auto;
}
.dg-row { display: flex; min-height: 28px; border-bottom: 1px solid var(--line-2); }
.dg-row:last-child { border-bottom: 0; }
.dg-label { flex: 0 0 270px; display: flex; align-items: flex-start; gap: 1px; padding: 5px 10px; font-size: 12px; border-right: 1px solid var(--line-2); background: var(--paper); white-space: normal; overflow: hidden; text-overflow: ellipsis; flex-direction: column; justify-content: center; position: sticky; left: 0; z-index: 5; box-shadow: 1px 0 0 var(--line-2); }
.dg-label b { font-weight: 650; flex: 0 0 auto; }
.dg-track { position: relative; flex: 0 0 auto; }
.dg-head { background: #FBFAF6; }
.dg-head .dg-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); flex-direction: row; align-items: center; }
.dg-month {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding-left: 6px;
  font-size: 10px; color: var(--ink-3); border-left: 1px solid var(--line-2);
  white-space: nowrap; overflow: hidden;
}
.dg-bar { position: absolute; top: 5px; height: 18px; border-radius: 4px; color: #fff; font-size: 9.5px; font-weight: 600; display: flex; align-items: center; padding: 0 5px; overflow: hidden; white-space: nowrap; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); z-index: 2; }
.dg-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .55; z-index: 1; }

.deals-main { min-width: 0; }

.dg-stage { font-size: 12px; font-weight: 600; line-height: 1.2; }
.dg-who { font-size: 10.5px; color: var(--ink-4); line-height: 1.2; }
/* ---------- инструменты диаграммы по сделке ---------- */

.acc-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dg-tools { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.dg-tools .seg button { padding: 5px 9px; font-size: 11.5px; }
.dg-fact {
  position: absolute; top: 24px; height: 2px; border-radius: 1px;
  background: #94B7A1; z-index: 3; pointer-events: none;
}
.dg-fact.is-late { background: #C08A3E; }
.dg-deadline {
  position: absolute; top: 2px; bottom: 2px; width: 2px; background: var(--accent);
  z-index: 4; pointer-events: none; border-radius: 1px;
}
.dg-deadline::before {
  content: ""; position: absolute; top: 0; left: -2px; width: 6px; height: 5px;
  border-radius: 1px; background: var(--accent);
}
.dg-legend {
  display: flex; align-items: center; gap: 6px; margin-top: 7px;
  font-size: 10.5px; color: var(--ink-4);
}
.dg-legend .lg-mark { margin-left: 8px; }
.dg-legend .lg-mark:first-child { margin-left: 0; }
.lg-mark { display: inline-block; width: 14px; height: 8px; border-radius: 2px; }
.lg-mark.bar { background: #4F7F5B; }
.lg-mark.fact { height: 2px; background: #94B7A1; }
.lg-mark.flag { width: 2px; height: 10px; border-radius: 1px; background: var(--accent); }

/* ---------- закупки ---------- */

.purch-filters { display: flex; gap: 10px; align-items: center; margin: 4px 0 14px; flex-wrap: wrap; }
.purch-filters .field.select { min-width: 260px; }
.purch-empty {
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 22px 18px; font-size: 13px; color: var(--ink-3);
}
.pg-fact {
  position: absolute; top: 2px; bottom: 2px; width: 2px; background: #4F7F5B;
  z-index: 4; pointer-events: none; border-radius: 1px;
}
.pg-fact.is-late { background: var(--accent); }
.pg-fact::before {
  content: ""; position: absolute; top: 0; left: -2px; width: 6px; height: 5px;
  border-radius: 1px; background: inherit;
}

/* ---------- таблица закупок ---------- */

.pt-c {
  flex: 0 0 auto; padding: 5px 6px; font-size: 11px; border-right: 1px solid var(--line-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3;
  display: flex; align-items: center;
}
.pt-n { width: 30px; justify-content: flex-end; color: var(--ink-4); font-size: 10.5px; }
.pt-sup { width: 130px; font-weight: 600; }
.pt-what { width: 180px; color: var(--ink-3); }
.pt-inv { width: 64px; font-family: var(--mono); font-size: 10px; }
.pt-dt { width: 70px; font-size: 10.5px; color: var(--ink-3); }
.pt-late { width: 56px; justify-content: flex-end; font-weight: 600; }
.pt-late.is-late { color: var(--accent); }
.dg-head .pt-c {
  font-size: 9px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-4); font-weight: 650;
}
.pg-needed { position: absolute; top: 2px; bottom: 2px; width: 1px; background: #8A6D3B; z-index: 4; }

/* ---------- закупки: таблица ввода ---------- */

.purch-table-wrap {
  overflow: auto; max-height: calc(100vh - 320px);
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 12px;
}
.purch-table { border-collapse: separate; border-spacing: 0; font-size: 11.5px; }
.purch-table th {
  position: sticky; top: 0; z-index: 2; background: #FBFAF6;
  border-bottom: 1px solid var(--line-2); padding: 8px; text-align: left;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-4); white-space: nowrap;
}
.purch-table td { padding: 3px 6px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.purch-table td.num { text-align: right; }
.purch-table td.warn { color: var(--accent); font-weight: 600; }
.purch-table input {
  height: 26px; border: 1px solid transparent; border-radius: 6px; padding: 0 5px;
  font: inherit; background: transparent;
}
.purch-table input:hover { border-color: var(--line-2); }
.purch-table input:focus { border-color: #BFC6CE; background: #fff; outline: none; }
.purch-table input[type="date"] { width: 118px; }
.purch-table .txt { width: 130px; }
.purch-table .txt-wide { width: 160px; }
.purch-table .txt-sm { width: 90px; }
.purch-table .num-in { width: 70px; text-align: right; }

.purch-gantt { max-height: calc(100vh - 330px); }

.purch-add-top { margin-left: auto; }

.purch-sup .sup-name { font-weight: 600; cursor: pointer; }
.purch-sup tbody tr { cursor: pointer; }
.purch-sup tbody tr:hover td { background: #FBFAF6; }

.purch-sup .sup-type-sel {
  height: 26px; border: 1px solid transparent; background: transparent; font: inherit;
  padding: 0 4px; border-radius: 6px; font-size: 11.5px;
}
.purch-sup .sup-type-sel:hover { border-color: var(--line-2); }
.purch-sup .sup-type-sel:focus { border-color: #BFC6CE; background: #fff; outline: none; }

/* ---------- карточка поставщика ---------- */

.purch-sup-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.purch-sup-layout.one { grid-template-columns: minmax(0, 1fr); }
.purch-side { position: sticky; top: 12px; }
.purch-side-body { padding: 0; }
.sup-inn, .sup-rating {
  width: 100%; height: 30px; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 0 8px; font: inherit; background: #fff;
}
.sup-contact {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 8px 0; border-top: 1px solid var(--line-2); position: relative;
}
.sup-contact input {
  height: 28px; border: 1px solid var(--line-2); border-radius: 7px; padding: 0 7px;
  font: inherit; font-size: 11.5px; background: #fff; min-width: 0;
}
.sup-contact .icon-btn { position: absolute; right: -2px; top: 6px; }
.sup-empty { font-size: 11.5px; color: var(--ink-4); padding: 6px 0; }
.sup-add-contact { margin-top: 8px; }
.sup-orders-btn { margin-top: 10px; width: 100%; }

.sup-name-input {
  width: 100%; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px;
  font-size: 15px; font-weight: 650; background: transparent; margin: 0 0 12px -6px;
}
.sup-name-input:hover { border-color: var(--line-2); }
.sup-name-input:focus { border-color: #BFC6CE; background: #fff; outline: none; }

.purch-view td.wrap { white-space: normal; max-width: 320px; line-height: 1.35; }
.purch-view td.claim { color: var(--accent); }
.purch-view td.soon { color: #8A6D3B; font-weight: 600; }
.purch-view th { font-size: 9.5px; }

/* единая типографика таблиц-отчётов (как на вкладке «Сделки») */
.purch-sup th, .purch-view th {
  padding: 10px 12px; font-size: 10px; letter-spacing: .06em;
}
.purch-sup td, .purch-view td { padding: 8px 12px; font-size: 12.5px; }
.purch-sup { font-size: 12.5px; }
.purch-view { font-size: 12.5px; }

.purch-data tbody tr { cursor: pointer; }
.purch-data tbody tr:hover td { background: #FBFAF6; }

/* ---------- компактная сводка ---------- */

.kpi-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.kpi-row .kpis { display: flex; gap: 8px; flex: 0 0 auto; }
.kpi-row .kpi {
  width: 128px; height: 50px; padding: 5px 9px 6px; border-radius: 10px;
  display: flex; flex-direction: column; justify-content: center;
}
.kpi-row .kpi-label { font-size: 8.5px; letter-spacing: .05em; }
.kpi-row .kpi-value { margin-top: 0; font-size: 15px; line-height: 1.15; }
.kpi-row .kpi-value small { font-size: 10px; }
.kpi-row .kpi-sub { margin-top: 1px; font-size: 8.5px; }
.kpi-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
