/* ============================================================
   tlv2.css — экран «Аналитика › Tiered Loyalty» (CRM-7966)
   Продуктовая версия дашборда эффективности TLv2.
   Все значения — через токены lp-kit (:root --lp-*). Шрифт Montserrat.
   Namespace: .tl-* (страница) + .tl-anav (вторичное меню аналитики).
   ============================================================ */

/* ---- палитра, производная от токенов LP ---- */
.tl-page, .tl-anav {
  --tl-blue: var(--lp-primary);      /* #457ce7 */
  --tl-ink: var(--lp-text);          /* #232829 */
  --tl-muted: var(--lp-gray-medium); /* #72747a */
  --tl-line: var(--lp-gray-light);   /* #d7d9d9 */
  --tl-card: var(--lp-white);
  --tl-bg: #f6f7f8;
  --tl-up: #1a7f43;                  /* рост — читаемый зелёный на белом */
  --tl-down: var(--lp-danger);       /* #b72d2a */
  --tl-purple: #6c5ce7;
  --tl-gold: #d4a017;
  /* тир-цвета */
  --tl-bronze: #b87333; --tl-silver: #9aa3ad; --tl-gold-tier: #d4a017; --tl-platinum: #6c5ce7;
  font-family: 'Montserrat','Roboto',Arial,sans-serif;
}

/* ---- раскладка: вторичное меню + контент ---- */
.tl-layout { display: flex; align-items: flex-start; gap: 28px; margin: -32px; }
.tl-anav {
  flex: 0 0 208px; align-self: stretch;
  background: var(--lp-white); border-right: 1px solid var(--tl-line);
  padding: 28px 0 40px; min-height: calc(100vh - 0px);
}
.tl-anav__section { padding: 0 20px; margin-bottom: 22px; }
.tl-anav__title { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--tl-muted); margin: 0 0 8px; }
.tl-anav ul { list-style: none; margin: 0; padding: 0; }
.tl-anav li { margin: 0; }
.tl-anav a {
  display: block; padding: 6px 10px; margin: 1px -10px; border-radius: var(--lp-radius);
  font-size: 13px; font-weight: 500; color: var(--tl-ink); text-decoration: none; cursor: pointer;
}
.tl-anav a:hover { background: var(--lp-gray-verylight); }
.tl-anav a.is-active { background: var(--lp-primary-tint); color: var(--lp-primary); font-weight: 600; }
.tl-anav .tl-anav__diamond { color: var(--lp-primary); margin-right: 6px; }

.tl-page { flex: 1 1 auto; min-width: 0; padding: 28px 32px 60px; }

/* ---- шапка страницы + фильтр периода ---- */
.tl-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 6px; }
.tl-head .tl-fresh { align-self: center; }
.tl-crumb { color: var(--tl-muted); font-size: 12px; margin-bottom: 4px; }
.tl-title { font-size: 24px; line-height: 32px; font-weight: 900; margin: 0; color: var(--tl-ink); }
.tl-sub { color: var(--tl-muted); font-size: 13px; margin: 4px 0 0; }
.tl-filterbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.tl-filterbar .tl-fld { min-width: 168px; }
.tl-fld > span { display: block; font-size: 11px; font-weight: 600; color: var(--tl-muted); margin-bottom: 4px; }

.tl-intro {
  font-size: 12.5px; color: #4a5058; background: var(--lp-primary-tint);
  border: 1px solid rgba(69,124,231,.28); border-radius: var(--lp-radius);
  padding: 10px 14px; margin: 14px 0 4px;
}
.tl-intro b { color: var(--tl-ink); }

/* ---- секции ---- */
.tl-sec { margin-top: 36px; }
.tl-sec__t { font-size: 18px; font-weight: 900; margin: 0 0 12px; color: var(--tl-ink); padding-bottom: 8px; border-bottom: 1px solid var(--tl-line); }

/* «на что смотреть» → сворачиваемая подсказка (продуктовый тон) */
.tl-hint { margin: 6px 0 14px; }
.tl-hint summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--lp-primary);
}
.tl-hint summary::-webkit-details-marker { display: none; }
.tl-hint summary svg { width: 14px; height: 14px; fill: currentColor; }
.tl-hint__body {
  font-size: 12.5px; color: #3a4150; background: var(--lp-gray-lightest);
  border-left: 3px solid var(--lp-primary); border-radius: 0 var(--lp-radius) var(--lp-radius) 0;
  padding: 9px 14px; margin-top: 8px;
}
.tl-hint__body b { color: var(--tl-ink); }

/* ---- KPI ---- */
.tl-kpis { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.tl-kpi {
  background: var(--tl-card); border: 1px solid var(--tl-line); border-radius: var(--lp-radius);
  padding: 15px 16px; display: flex; flex-direction: column;
}
.tl-kpi__l { color: var(--tl-muted); font-size: 12px; font-weight: 600; }
.tl-kpi__v { font-size: 26px; font-weight: 700; margin: 5px 0 2px; line-height: 1; color: var(--tl-ink); }
.tl-kpi__d { font-size: 12px; color: #5a616b; }
.tl-kpi__m { font-size: 11px; color: #3a4150; margin-top: 9px; border-top: 1px dashed var(--tl-line); padding-top: 7px; }
.tl-kpi__f { font-size: 10px; color: #9aa3ad; margin-top: 5px; }
.tl-up { color: var(--tl-up); font-weight: 700; }
.tl-down { color: var(--tl-down); font-weight: 700; }

/* ---- панели/сетки/таблицы ---- */
.tl-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tl-panel {
  background: var(--tl-card); border: 1px solid var(--tl-line); border-radius: var(--lp-radius);
  padding: 16px; margin-top: 14px;
}
.tl-pt { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: #4a5058; }
.tl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tl-table th, .tl-table td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--tl-line); }
.tl-table th:first-child, .tl-table td:first-child { text-align: left; }
.tl-table th { color: var(--tl-muted); font-weight: 600; font-size: 12px; }
.tl-table tr:last-child td { border-bottom: none; }
.tl-badge { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.tl-note { color: var(--tl-muted); font-size: 11px; margin-top: 8px; }
.tl-note b { color: #4a5058; }

/* легенда графиков */
.tl-lg { margin: 2px 0 6px; }
.tl-lg span { font-size: 11px; margin-right: 14px; color: #5a616b; }
.tl-lg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.tl-lg b { color: var(--tl-ink); }
.tl-lgh { color: #9aa3ad; margin-right: 8px; }

/* методика — сворачиваемая */
.tl-defs { margin-top: 10px; }
.tl-defs summary { cursor: pointer; color: #9aa3ad; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.tl-def { display: flex; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--tl-line); }
.tl-dn { flex: 0 0 200px; font-weight: 600; color: #3a4150; font-size: 11.5px; }
.tl-dd { color: #6b7280; font-size: 11.5px; } .tl-dd b { color: #4a5160; font-weight: 600; }

/* chip / warn / soon */
.tl-chip { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .4px; color: #fff; background: var(--lp-primary); border-radius: 10px; padding: 2px 8px; vertical-align: middle; margin-left: 6px; }
.tl-chip.soft { background: #9aa3ad; }
.tl-soon {
  border: 1px dashed #c4ccd6; border-radius: var(--lp-radius);
  background: repeating-linear-gradient(45deg,#fcfdfe,#fcfdfe 12px,#f6f8fb 12px,#f6f8fb 24px);
}
.tl-flist { columns: 2; font-size: 12.5px; color: #3a4150; margin: 6px 0; padding-left: 18px; }
.tl-flist li { margin: 5px 0; break-inside: avoid; }
.tl-burn { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.tl-burn__v { font-size: 36px; font-weight: 700; color: var(--tl-gold); line-height: 1.1; }

/* ---- подписи контролов бара ---- */
.tl-ctl-lbl { font-size: 12px; font-weight: 600; color: var(--tl-muted); }

/* ---- легенда графика (сплошная = текущий, пунктир = сравнение) ---- */
.tl-clg { display: flex; flex-wrap: wrap; gap: 16px; margin: 2px 0 8px; font-size: 11.5px; color: #5a616b; }
.tl-clg span { display: inline-flex; align-items: center; gap: 6px; }
.tl-clg i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--c); }
.tl-clg i.d { border-top-style: dashed; opacity: .6; }

/* ---- графики (рисуются в tlv2.js) ---- */
.tl-chart { position: relative; margin-top: 4px; }
.tl-svg { display: block; }
.tl-tip {
  position: absolute; transform: translateX(-50%);
  background: var(--tl-ink); color: #fff; border-radius: 6px; padding: 8px 10px;
  font-size: 12px; line-height: 1.35; pointer-events: none; z-index: 20; white-space: nowrap;
  box-shadow: rgba(0,0,0,.25) 0 6px 20px;
}
.tl-tip__h { font-weight: 700; margin-bottom: 4px; }
.tl-tip__r { display: flex; align-items: center; gap: 6px; }
.tl-tip__r i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.tl-spacer { flex: 1 1 auto; }

/* ---- бар периода/детализации/сравнения (каждый контрол — своя строка) ---- */
.tl-cmpbar { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 2px; }
.tl-ctlrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tl-ctl-lbl { width: 104px; flex: none; font-size: 12px; font-weight: 700; color: var(--tl-muted); }
.tl-daterange { display: inline-flex; align-items: center; gap: 8px; }
.tl-dash { color: var(--tl-muted); }
.tl-date { height: 36px; border: 1px solid var(--tl-line); border-radius: var(--lp-radius); padding: 0 10px; font: 500 13px Montserrat; color: var(--tl-ink); background: #fff; }
.tl-legacy-cmpbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tl-seg { display: inline-flex; height: 36px; background: #fff; border: 1px solid var(--tl-line); border-radius: var(--lp-radius); overflow: hidden; }
.tl-seg button { border: none; background: #fff; color: var(--tl-muted); font: 500 13px Montserrat; padding: 0 15px; height: 100%; cursor: pointer; }
.tl-seg button.on { background: var(--lp-primary); color: #fff; font-weight: 700; }
.tl-cmpdetail { color: var(--tl-muted); font-size: 12.5px; }
.tl-cmpbar { align-items: flex-start; }
.tl-range { display: inline-flex; align-items: center; gap: 7px; height: 36px; background: #fff; border: 1px solid var(--tl-line); border-radius: var(--lp-radius); padding: 0 12px; font-size: 13px; }
.tl-range svg { width: 14px; height: 14px; fill: var(--tl-muted); }
.tl-range b { font-weight: 700; }
.tl-cmpfld { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--tl-muted); }
.tl-cmpsel { height: 36px; font: 500 13px Montserrat; color: var(--tl-ink); background: #fff; border: 1px solid var(--tl-line); border-radius: var(--lp-radius); padding: 0 10px; cursor: pointer; }
.tl-cpick { display: flex; gap: 10px; }
.tl-picker { position: relative; background: #fff; border: 1px solid var(--tl-line); border-radius: var(--lp-radius); padding: 8px 13px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; user-select: none; }
.tl-picker .lbl { color: var(--tl-muted); } .tl-picker b { font-weight: 700; }
.tl-picker .cv { width: 12px; height: 12px; fill: var(--tl-muted); transition: transform .15s; }
.tl-picker.open .cv { transform: rotate(180deg); }
.tl-pmenu { position: absolute; top: calc(100% + 4px); right: 0; min-width: 180px; background: #fff; border: 1px solid var(--tl-line); border-radius: var(--lp-radius); box-shadow: var(--lp-shadow-float); padding: 5px; z-index: 60; display: none; max-height: 280px; overflow: auto; }
.tl-picker.open .tl-pmenu { display: block; }
.tl-pmenu .opt { padding: 8px 11px; border-radius: var(--lp-radius); font-size: 13px; color: var(--tl-ink); white-space: nowrap; cursor: pointer; }
.tl-pmenu .opt:hover { background: var(--lp-primary-tint); }
.tl-pmenu .opt.sel { color: var(--lp-primary); font-weight: 700; }
.tl-pmenu .opt.dis { color: #c9ccce; cursor: not-allowed; }

/* свежесть данных + баннер незавершённого периода */
.tl-fresh { color: var(--tl-muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tl-fresh svg { width: 14px; height: 14px; fill: var(--tl-muted); }
.tl-banner { display: none; align-items: center; gap: 9px; background: #fff7e6; border: 1px solid #ffd98a; color: #7a5a10; border-radius: var(--lp-radius); padding: 9px 13px; font-size: 12.5px; margin: 12px 0 0; }

/* norm chip + delta + info-i */
.tl-kpi__norm { display: inline-block; margin-top: 8px; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 20px; align-self: flex-start; cursor: help; border-bottom: 1px dotted transparent; }
.tl-kpi__norm:hover { filter: brightness(.97); }
.tl-kpi__norm.hi { background: #e7f6ee; color: #1a7f43; }
.tl-kpi__norm.mid { background: var(--lp-gray-verylight); color: var(--tl-muted); }
.tl-kpi__norm.lo { background: #fff7e6; color: #8a5a00; }
.tl-flat { color: var(--tl-muted); font-weight: 700; }
.tl-kpi__d .b { color: var(--tl-muted); font-weight: 400; }
.info-i { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--tl-line); color: var(--tl-muted); font-size: 9px; font-weight: 700; margin-left: 5px; vertical-align: middle; cursor: pointer; font-style: normal; }
[data-info] { cursor: pointer; }
[data-info]:hover > .tl-pt .info-i, [data-info]:hover .info-i { border-color: var(--lp-primary); color: var(--lp-primary); }

/* info modal (клик по «i») */
.tl-mbg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 120; padding: 60px 16px; overflow: auto; }
.tl-mbg.show { display: block; }
.tl-modal { max-width: 520px; margin: 0 auto; background: #fff; border-radius: 8px; padding: 22px 24px; box-shadow: rgba(0,0,0,.2) 0 12px 40px; }
.tl-mh { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.tl-mh .mt { font-size: 18px; font-weight: 900; }
.tl-mh .mx { cursor: pointer; color: var(--tl-muted); font-size: 26px; line-height: .7; }
.tl-mlabel { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tl-muted); margin-bottom: 6px; }
.tl-mdef { font-size: 14px; line-height: 1.55; margin-bottom: 16px; }
.tl-mform { background: var(--lp-gray-lightest); border: 1px solid var(--tl-line); border-radius: var(--lp-radius); padding: 12px 14px; font-size: 13.5px; line-height: 1.5; margin-bottom: 16px; }
.tl-mcmp { font-size: 12.5px; color: var(--tl-muted); border-top: 1px solid var(--tl-line); padding-top: 12px; line-height: 1.5; } .tl-mcmp b { color: var(--tl-ink); }
.tl-mlist { margin: 8px 0 10px; padding-left: 20px; } .tl-mlist li { margin: 4px 0; }

/* ---- 90-дневные метрики (KFC): круглые медальоны + прирост ---- */
.tl-90wrap { background: var(--tl-card); border: 1px solid var(--tl-line); border-radius: var(--lp-radius); padding: 22px 16px; margin-top: 14px; }
.tl-90 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; justify-items: center; }
.tl-90__item { display: flex; flex-direction: column; align-items: center; text-align: center; }
.tl-circle {
  width: 150px; height: 150px; border-radius: 50%;
  background: var(--lp-primary); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 14px;
}
.tl-circle__v { font-size: 32px; font-weight: 900; line-height: 1; }
.tl-circle__l { font-size: 12px; font-weight: 700; margin-top: 7px; line-height: 1.2; }
.tl-circle__s { font-size: 10px; font-weight: 500; opacity: .82; margin-top: 3px; line-height: 1.15; }
.tl-90__grow { margin-top: 12px; }
.tl-90__grow b { display: block; font-size: 20px; font-weight: 900; color: var(--tl-up); line-height: 1; }
.tl-90__grow span { font-size: 11px; color: var(--tl-muted); }

/* ---- CLTV 30/60/90D — сгруппированные столбцы ---- */
.tl-clv-lg span { font-size: 11px; margin-right: 14px; color: #5a616b; }
.tl-clv-lg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

@media (max-width: 1100px) {
  .tl-kpis { grid-template-columns: repeat(2,1fr); }
  .tl-grid2 { grid-template-columns: 1fr; }
  .tl-90 { grid-template-columns: repeat(2,1fr); }
}
