/* Elements of design/element-map.md §2 (names follow design/src/ui.py). Colours only via tokens. */

/* ---------------------------------------------------------------- btn */
.btn {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  height: 42px; padding: 0 20px;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent; border-radius: 0; box-shadow: none;
  background: transparent; color: var(--ink); text-decoration: none;
}
.btn .ico { width: 16px; height: 16px; }
.btn--sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn--primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--black { background: var(--black); color: var(--on-black); border-color: var(--black); }
.btn--beige { background: var(--beige); color: var(--ink); border-color: var(--beige); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn--cancel { background: var(--cancel); color: var(--on-btn); border-color: var(--cancel); }
.btn:disabled, .btn--disabled { background: var(--disabled); color: var(--on-btn); border-color: var(--disabled); cursor: default; }
a.btn--ghost:hover, a.btn--beige:hover { color: var(--ink); }
a.btn--primary:hover { color: var(--on-accent); }
.btn--block { width: 100%; justify-content: center; height: 48px; font-size: 15px; }
.btn--regular { font-weight: 400; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 36px; height: 36px; padding: 0;
  background: transparent; border: 1px solid var(--line-2); border-radius: 0; color: var(--ink-2);
}

/* ---------------------------------------------------------------- field, select */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { display: flex; align-items: center; gap: 2px; height: 16px; }
.field__label label, .field__label > span:first-child {
  font-size: 12px; font-weight: 500; color: var(--ink-2); letter-spacing: 0.02em; line-height: 16px;
}
.field__input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 0; font-size: 14px;
}
.field__input::placeholder { color: var(--ink-3); }
.field--err .field__input { border-color: var(--err-ink); }
.field__hint { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.field__err { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--err-ink); }

.select { position: relative; width: 100%; }
.select select {
  width: 100%; height: 40px; padding: 0 34px 0 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 0; font-size: 14px;
  appearance: none; -webkit-appearance: none;
}
.select .ico { position: absolute; right: 9px; top: 10px; color: var(--ink-2); pointer-events: none; }
/* the list a native select opens (backlog 04.10 №1, Chromium on Windows: a white list with light items in the dark theme):
   the scheme of the theme on the select itself and solid colours of A9 on every item — the panel and the administration */
select { color-scheme: inherit; }
select option, select optgroup { background-color: var(--surface); color: var(--ink); }
select option:disabled { color: var(--ink-3); }

/* ---------------------------------------------------------------- toggle, checkbox */
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle__box { position: relative; display: inline-block; width: 36px; height: 20px; background: var(--line-2); flex-shrink: 0; }
.toggle__knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--surface); }
.toggle input:checked + .toggle__box { background: var(--accent); }
.toggle input:checked + .toggle__box .toggle__knob { left: 18px; }
.toggle input:focus-visible + .toggle__box { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle__label { font-size: 13px; color: var(--ink); white-space: nowrap; }

.checkbox { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox__mark {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 16px; height: 16px; background: var(--beige); border: 1px solid var(--line-2); color: var(--on-accent);
}
.checkbox__mark .ico { visibility: hidden; }
.checkbox input:checked + .checkbox__mark { background: var(--accent); border-color: var(--accent); }
.checkbox input:checked + .checkbox__mark .ico { visibility: visible; }
.checkbox input:focus-visible + .checkbox__mark { outline: 2px solid var(--accent); outline-offset: 2px; }
.checkbox__label { font-size: 13px; color: var(--ink); }
/* a tick that cannot be changed (no right, ФП-p1-22): the mark of a disabled control, the label dimmed */
.checkbox--disabled { cursor: default; }
.checkbox--disabled .checkbox__mark { background: var(--disabled); border-color: var(--disabled); }
.checkbox--disabled .checkbox__label { color: var(--ink-3); }

/* ---------------------------------------------------------------- fchip, segmented */
.fchip {
  position: relative; display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  height: 38px; padding: 0 10px 0 12px;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink);
  text-align: left; border-radius: 0;
}
.fchip__label { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.fchip__value {
  flex-grow: 1; min-width: 0; font-size: 13px; font-weight: 500; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fchip select {
  flex-grow: 1; min-width: 0; height: 100%; padding: 0;
  background: transparent; border: 0; color: var(--ink); font-size: 13px; font-weight: 500;
  appearance: none; -webkit-appearance: none; cursor: pointer;
}
.fchip--native .fchip__value { overflow: visible; }
.fchip--native select { position: absolute; inset: 0; width: 100%; opacity: 0; }
.fchip--native:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.fchip > .ico, .fchip__btn > .ico { color: var(--ink-2); pointer-events: none; flex-shrink: 0; }
.fchip__btn {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 100%; min-width: 0; padding: 0;
  background: transparent; border: 0; border-radius: 0; color: var(--ink); text-align: left;
}
.fchip:has(.fchip__btn) { padding: 0; }
.fchip:has(.fchip__btn) .fchip__btn { padding: 0 10px 0 12px; }

.segmented { display: flex; align-items: center; gap: 8px; }
.segmented__label { font-size: 12px; color: var(--ink-3); }
.segmented__box { display: flex; align-items: stretch; height: 38px; background: var(--surface); border: 1px solid var(--line-2); overflow: hidden; }
.segmented__btn {
  height: 36px; padding: 0 12px; white-space: nowrap;
  background: transparent; color: var(--ink-2);
  border: 0; border-right: 1px solid var(--line-2); border-radius: 0; font-size: 13px; font-weight: 400;
}
.segmented__btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 500; }

/* ---------------------------------------------------------------- badge, note */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  background: var(--line); color: var(--ink-2);
  font-size: 12px; font-weight: 500; letter-spacing: 0.02em; white-space: nowrap; line-height: 1;
}
.badge--demo { background: var(--demo-bg); color: var(--demo-ink); }
.badge--real { background: var(--real-bg); color: var(--real-ink); }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge--err { background: var(--err-bg); color: var(--err-ink); }
.badge__sq { display: none; width: 8px; height: 8px; flex-shrink: 0; background: var(--err-ink); }
/* A9: red text on #343539 is 3.6:1 — in the dark theme the text is light and the colour sits in a square */
:root[data-theme="dark"] .badge--err { color: var(--ink); }
:root[data-theme="dark"] .badge--err .badge__sq { display: inline-block; }
.badge--pending { background: var(--warn-bg); color: var(--warn-ink); border: 1px dashed var(--warn-ink); }
.badge--pending.badge--sm { height: 18px; padding: 0 6px; font-size: 10px; }

.note {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: var(--plaque-bg); color: var(--plaque-ink); font-size: 13px; line-height: 1.45;
}
.note__ico { flex-shrink: 0; margin-top: 1px; color: var(--ink-2); }
.note__text { flex-grow: 1; }
.note--warn, .note--err, .note--ok { border-left: 3px solid; padding-left: 11px; }
.note--warn { border-left-color: var(--warn-mark); } .note--warn .note__ico { color: var(--warn-mark); }
.note--err { border-left-color: var(--err-mark); } .note--err .note__ico { color: var(--err-mark); }
.note--ok { border-left-color: var(--ok-mark); } .note--ok .note__ico { color: var(--ok-mark); }

/* ---------------------------------------------------------------- help dot, search */
.help-dot {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 20px; height: 20px; padding: 0; background: transparent; border: 0;
  color: var(--ink-3); cursor: help; vertical-align: middle;
}
.search-box { position: relative; flex-shrink: 0; }
.search-box .ico { position: absolute; left: 10px; top: 9px; color: var(--ink-3); pointer-events: none; }
.search-box input {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 0; font-size: 13px;
  -webkit-appearance: none; appearance: none;
}
.search-box input::placeholder { color: var(--ink-3); }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------------------------------------------------------------- blocks */
.card { background: var(--surface); border: 1px solid var(--line); padding: 24px; min-width: 0; }
.block-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.block-title h2 { display: flex; align-items: center; gap: 4px; font-family: var(--font-display); font-size: 20px; line-height: 26px; font-weight: 400; letter-spacing: 0.01em; }
.block-title__sub { font-size: 13px; line-height: 18px; color: var(--ink-3); }

.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-title__main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.page-title h1 {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-size: 27px; line-height: 32px; font-weight: 400; letter-spacing: 0.01em; color: var(--ink);
}
.page-title__sub { font-size: 13px; line-height: 18px; color: var(--ink-2); }
.page-title__right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.tabs { display: flex; align-items: center; margin-bottom: 20px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; flex-shrink: 0; height: 38px; padding: 0 2px; margin-right: 22px;
  color: var(--ink-2); font-size: 14px; font-weight: 400; text-decoration: none; border-bottom: 2px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--accent); }
.tabs__item { display: inline-flex; align-items: center; flex-shrink: 0; gap: 2px; margin-right: 22px; }
.tabs__item a { margin-right: 0; }

.kpi-row { display: flex; gap: 16px; }
.kpi {
  flex: 1 1 0; min-width: 0; background: var(--surface); border: 1px solid var(--line);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.kpi__label { display: flex; align-items: center; gap: 2px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-2); letter-spacing: 0.02em; }
.kpi__value { font-family: var(--font-display); font-size: 32px; line-height: 1; color: var(--ink); }
.kpi__value--g-high { color: var(--g-high); }
.kpi__value--g-low { color: var(--g-low); }
.kpi__sub { font-size: 12px; line-height: 1.35; color: var(--ink-3); }

.dash { color: var(--ink-3); }
/* a dash with its reason (ФП-p1-19): the same «—», the W text on hover and on a click */
.dash--why { padding: 0; background: transparent; border: 0; font: inherit; line-height: inherit; cursor: help; }

/* ---------------------------------------------------------------- chips: brand, grade, neutral */
.brand-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); white-space: nowrap; }
.sq { display: inline-block; flex-shrink: 0; width: 10px; height: 10px; }
.sq--8 { width: 8px; height: 8px; }
.sq--erayba { background: var(--brand-erayba-f); }
.sq--marjinal { background: var(--brand-marjinal-f); }
.sq--drsorbie { background: var(--brand-drsorbie-f); }
.sq--series { background: var(--series); }
.sq--neutral { background: var(--ink); }
.sq--empty { background: var(--g-dash-f); border: 1px solid var(--g-dash-bd); }
.sq--g-high { background: var(--g-high-f); }
.sq--g-mid { background: var(--g-mid-f); }
.sq--g-ok { background: var(--g-ok-f); }
.sq--g-low { background: var(--g-low-f); }
.sq--g-dash { background: var(--g-dash-grade); }
/* З-10, ПЗ-10 (A v96.5): «Вне KPI» — green as «Высокая», told apart by hatching of g_high_f over the surface */
.sq--g-out { background: repeating-linear-gradient(135deg, var(--g-high-f) 0 3px, var(--surface) 3px 5px); }
.grade-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.grade-chip--g-high { color: var(--g-high); }
.grade-chip--g-mid { color: var(--g-mid); }
.grade-chip--g-ok { color: var(--g-ok); }
.grade-chip--g-low { color: var(--g-low); }
.grade-chip--g-dash { color: var(--g-dash); }
.grade-chip--g-out { color: var(--g-high); }
.brand-text--erayba { color: var(--brand-erayba); }
.brand-text--marjinal { color: var(--brand-marjinal); }
.brand-text--drsorbie { color: var(--brand-drsorbie); }

/* ---------------------------------------------------------------- states (element-map §2.5, Э-1.3) */
.state-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px;
  border: 1px dashed var(--line-2); text-align: center;
}
.state-empty__ico { color: var(--ink-3); }
.state-empty__title { font-size: 15px; }
.state-empty__text { font-size: 13px; color: var(--ink-3); }
.skeleton { display: flex; flex-direction: column; gap: 8px; }
.skeleton__row { display: flex; gap: 12px; }
.skeleton__row span { height: 14px; background: var(--line); }
.state-error { display: flex; flex-direction: column; gap: 12px; }
.state-error__actions { display: flex; gap: 10px; }

/* ---------------------------------------------------------------- dropdown panel (filters) */
.popover {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: -1px;
  min-width: 100%; padding: 6px 0;
  background: var(--surface); border: 1px solid var(--line-2);
}
.popover--chats { width: 262px; }
.popover--end { left: auto; right: -1px; }
.popover__row { display: flex; align-items: center; height: 36px; padding: 0 12px; }
.popover__row--all { height: 38px; }
.popover__row .checkbox { width: 100%; height: 100%; }
.popover__sep { height: 1px; margin: 4px 0; background: var(--line); }
.popover--dates { width: 336px; padding: 12px; }
.popover--dates .popover__form { display: flex; flex-direction: column; gap: 14px; }
.popover__foot { display: flex; justify-content: flex-end; gap: 10px; }
.popover__dates { display: flex; gap: 12px; }
.popover__dates .field { width: 150px; }

/* ---------------------------------------------------------------- charts (theme/charts.js, A9 «Графики») */
.chart { display: block; overflow: visible; }
.chart text { font-family: var(--font-body); }
.ch-grid { stroke: var(--grid); stroke-width: 1; }
.ch-axis { stroke: var(--line-2); stroke-width: 1; }
.ch-ink { fill: var(--ink); }
.ch-ink2 { fill: var(--ink-2); }
.ch-ink3 { fill: var(--ink-3); }
.ch-outline { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.ch-tip { fill: #111111; }
.ch-tip-ink { fill: #FFFFFF; }
:root[data-theme="dark"] .ch-tip { fill: var(--line); stroke: #686C76; stroke-width: 1; }
:root[data-theme="dark"] .ch-tip-ink { fill: var(--ink); }
.ch-hit { cursor: pointer; }
.ch-line { stroke: var(--series-line); stroke-width: 2; }
.ch-line-ink { fill: var(--series-line); }
.ch-point { fill: var(--surface); stroke: var(--series-line); stroke-width: 2; }
.legend__line { display: inline-block; width: 10px; height: 3px; flex-shrink: 0; }
.legend { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }

/* ---------------------------------------------------------------- tables (element-map table) */
.tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
/* headers (замечания заказчицы 29.09, п. 5): centred, wrapped by words only; the last word keeps its «?» (thLabel) */
.tbl th {
  padding: 10px 12px; text-align: center; vertical-align: bottom; white-space: normal; overflow-wrap: normal; hyphens: none;
  font-size: 12px; font-weight: 500; color: var(--ink-2); letter-spacing: 0.02em;
  background: var(--surface); border-bottom: 1px solid var(--line-2);
}
/* rows by the centre, long text by the left (ПИ 117, О-8, 07.10: «заголовки и строки по центру; длинный текст — по левому
   краю, короткий — по центру»); .tl is set by fitTables on the text columns and clamped cells */
.tbl td, .tbl td.num { text-align: center; }
.tbl td.tl { text-align: left; }
.tbl td.tc { text-align: center; }
/* a row with a sign — lead, unique circle theme: a 4 px stripe of --ok-mark at the left edge, no fill (map 1.22, rule 22) */
.tbl tr.row-mark > td:first-child { box-shadow: inset 4px 0 0 var(--ok-mark); }
.tbl th .help-dot { margin-left: 2px; }
.tbl--wrap th { white-space: normal; }
.tbl td {
  padding: 11px 12px; vertical-align: top; font-size: 13px; line-height: 1.4; color: var(--ink);
  border-bottom: 1px solid var(--line); overflow-wrap: normal;
}
/* words break only between them (ПЭ-p-req-03); a long text and its links may break anywhere */
.tbl td.tl { overflow-wrap: anywhere; }
/* long text in a cell: 3 lines and «…», opened in place by a click (fitTables / bindTables in ui.js) */
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.clamp--cut { cursor: pointer; }
.clamp--open { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; }
.clamp-foot { margin-top: 6px; font-size: 12px; }
.clamp-foot a { color: var(--ink-2); }
.tbl--sm td { font-size: 12px; }
.tbl tr.tbl__total td { font-weight: 500; }
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl tbody tr[aria-selected="true"] td { background: var(--beige); }

.row { display: flex; gap: 20px; align-items: stretch; }
.grow { flex: 1 1 0; min-width: 0; }
.red { color: var(--g-low); }
.green { color: var(--g-high); }
.muted { color: var(--ink-3); }
.fw500 { font-weight: 500; }

/* ---------------------------------------------------------------- «?» pair and hint card (theme/hint.js) */
.help-pair { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; max-width: 100%; }
.help-pair--block { display: flex; width: 100%; }
.help-pair--block > .btn, .help-pair--block > .search-box, .help-pair--block > .select, .help-pair--block > .mfilter { flex: 1 1 auto; min-width: 0; }
.hint-pop {
  position: fixed; z-index: 60; width: 300px; max-width: calc(100vw - 32px); padding: 12px 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2);
  font-size: 13px; line-height: 18px;
}
.hint-pop__title { font-weight: 500; margin-bottom: 4px; }
.hint-pop__body { color: var(--ink-2); overflow-wrap: anywhere; }
