/* Общие стили демо-кабинета. Токены цвета и шрифтов — tokens.css и fonts.css (собираются из widget/).
   Размеры и позиции — по макетам Figma «Admin · Отчёты» (216:3), «Admin · Новая точка» (243:282),
   «Telegram · Еженедельный отчёт» (246:16). */

:root {
  --gray-100: #f3f3f4;
  --gray-200: #e4e4e7;
  --gray-400: #bfbfbf;
  --gray-500: #71717a;
  --gray-950: #18181b;
  --green-label: #5b8a00;
  --heading-h2-size: 28px;
  --heading-h2-line-height: 36px;
  --heading-h3-size: 24px;
  --heading-h3-line-height: 32px;
  --body-regular-size: 16px;
  --body-regular-line-height: 28px;
  --body-caption-size: 12px;
  --body-caption-line-height: 20px;
  --ui-label-size: 14px;
  --ui-label-line-height: 20px;
  --ui-button-size: 16px;
  --ui-button-line-height: 24px;
  --ui-button-small-size: 14px;
  --ui-button-small-line-height: 20px;
  --topbar-h: 72px;
  --side-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-family: var(--font-text);
  font-size: var(--body-regular-size);
  line-height: var(--body-regular-line-height);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.op-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- шапка ---------- */
.op-top {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border-default);
  display: flex; align-items: center; gap: 16px;
  padding: 0 32px;
}
.op-logo { display: block; width: 77px; height: 20px; flex: none; background: var(--color-text-primary);
  -webkit-mask: url(../assets/logo-mask.png) no-repeat 0 0 / 77px 20px; mask: url(../assets/logo-mask.png) no-repeat 0 0 / 77px 20px; }
.op-demo {
  display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px;
  border-radius: var(--radius-full); background: rgba(24, 24, 27, 0.06);
  font-size: 12px; line-height: 16px; font-weight: 500; color: var(--color-text-secondary); white-space: nowrap;
}
.op-demo::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--color-status-warning); }
.op-top__right { margin-left: auto; display: flex; align-items: center; gap: 24px; min-width: 0; }
.op-exit { background: none; border: 0; padding: 0; font-size: var(--body-regular-size); line-height: var(--body-regular-line-height); color: var(--color-text-primary); opacity: 0.55; cursor: not-allowed; }

/* ---------- боковое меню ---------- */
.op-side {
  position: fixed; left: 0; top: var(--topbar-h); bottom: 0; width: var(--side-w); z-index: 20;
  background: var(--color-bg-card); border-right: 1px solid var(--color-border-default);
  padding: 24px 16px; overflow-y: auto;
}
.op-nav { display: flex; flex-direction: column; gap: 4px; }
.op-nav a {
  display: flex; align-items: center; height: 44px; padding: 0 16px; border-radius: 12px; text-decoration: none;
  color: var(--color-text-secondary); font-size: var(--body-regular-size); transition: background var(--dur-fast) var(--ease-standard);
}
.op-nav a:hover { background: rgba(243, 243, 244, 0.7); }
.op-nav a[aria-current='page'] { background: var(--gray-100); color: var(--color-text-primary); font-weight: 600; }

/* ---------- страница ---------- */
.op-main { margin-left: var(--side-w); padding: 32px 40px 56px; min-width: 0; }
.op-page { max-width: 1120px; margin: 0 auto 0 0; min-width: 0; }
.op-h1 {
  font-family: var(--font-display); font-weight: 600; font-size: var(--heading-h2-size); line-height: var(--heading-h2-line-height);
  letter-spacing: -0.28px;
}
.op-h3 {
  font-family: var(--font-display); font-weight: 600; font-size: var(--heading-h3-size); line-height: var(--heading-h3-line-height);
  letter-spacing: -0.24px;
}
.op-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; min-height: 40px; }
.op-head__tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.op-back { display: inline-flex; align-items: center; gap: 6px; font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; color: var(--color-text-secondary); text-decoration: none; margin-bottom: 8px; }
.op-back:hover { color: var(--color-text-primary); }

.op-card { background: var(--color-bg-card); border-radius: var(--radius-lg); padding: 24px; min-width: 0; }
.op-cap { font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; color: var(--green-label); text-transform: uppercase; }
.op-sub { color: var(--color-text-secondary); }
.op-muted { color: var(--color-text-secondary); }

/* ---------- сегмент, селект, кнопки ---------- */
.op-seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--radius-full); background: var(--gray-100); }
.op-seg button {
  border: 0; background: none; padding: 6px 16px; border-radius: var(--radius-full);
  font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; color: var(--color-text-secondary); white-space: nowrap;
}
.op-seg button[aria-pressed='true'] { background: var(--color-bg-card); color: var(--color-text-primary); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.op-seg--sm button { padding: 4px 12px; }
.op-pill { position: relative; display: inline-flex; align-items: center; height: 40px; border-radius: var(--radius-full); background: var(--gray-100); max-width: 100%; }
.op-pill select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; height: 100%; padding: 0 38px 0 16px; border-radius: var(--radius-full);
  font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; cursor: pointer; max-width: 100%; text-overflow: ellipsis;
}
.op-pill svg { position: absolute; right: 14px; top: 50%; margin-top: -8px; pointer-events: none; }
.op-pill:focus-within, .op-seg button:focus-visible, .op-btn:focus-visible, .op-row:focus-visible, a:focus-visible, .op-x:focus-visible, .op-pg:focus-visible, .op-fp:focus-within, .op-sf:focus-visible, .op-tp:focus-visible, .op-doc:focus-visible, .op-bal-chip:focus-visible {
  outline: 2px solid var(--gray-950); outline-offset: 2px;
}
.op-pill select:focus { outline: none; }

.op-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 22px 0 18px; border: 0; border-radius: var(--radius-full);
  background: var(--color-accent); color: var(--color-text-primary); font-size: var(--ui-button-size); line-height: var(--ui-button-line-height); font-weight: 600; white-space: nowrap;
  text-decoration: none;
}
.op-btn--soft { background: var(--gray-100); }
.op-btn--sm { height: 36px; padding: 0 16px; font-size: var(--ui-label-size); gap: 6px; }
.op-btn--wide { height: 52px; padding: 0 28px; }
.op-btn[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; }
.op-link { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-position: from-font; text-align: left; }
.op-link--soft { color: var(--color-text-secondary); font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; text-decoration: none; }
.op-link--soft:hover { color: var(--color-text-primary); }

/* подсказка «В демо недоступно» */
[data-demo-off] { position: relative; }
[data-demo-off]::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  background: var(--gray-950); color: #fff; font-size: var(--body-caption-size); line-height: var(--body-caption-line-height); font-weight: 400;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none; display: none; z-index: 40;
}
/* display:none, а не opacity:0 — невидимая подсказка иначе растягивает страницу вправо */
[data-demo-off]:hover::after, [data-demo-off]:focus-visible::after { display: block; transform: translateX(-50%); }
.op-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100; background: var(--gray-950); color: #fff; border-radius: var(--radius-full);
  padding: 10px 20px; font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; opacity: 0; pointer-events: none; transition: opacity var(--dur-medium);
  max-width: calc(100vw - 32px);
}
.op-toast.is-on { opacity: 1; }

/* ---------- статусы и превью ---------- */
.op-badge { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 10px; border-radius: var(--radius-full); background: var(--gray-100); font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; white-space: nowrap; }
.op-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--gray-400); }
.op-thumb {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: 8px; overflow: hidden;
  background-color: var(--gray-100); background-repeat: no-repeat; color: var(--gray-400);
}
.op-thumb--none { font-size: var(--body-regular-size); }
.op-thumb--stub { background: var(--gray-100); }
.op-thumbs { display: flex; gap: 8px; justify-content: flex-end; }

/* подсказка под элементом (для кнопок в шапке) */
[data-demo-off][data-below]::after { bottom: auto; top: calc(100% + 8px); left: auto; right: 0; transform: translateY(-4px); }
[data-demo-off][data-below]:hover::after, [data-demo-off][data-below]:focus-visible::after { transform: none; }

/* ---------- таблицы ---------- */
.op-tr { display: grid; align-items: center; border-bottom: 1px solid var(--color-border-default); }
.op-tr--head { height: 40px; font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; color: var(--color-text-secondary); }
.op-row { min-height: 64px; padding: 0; }
.op-table .op-row:last-child { border-bottom: 0; }
.op-row[data-try] { cursor: pointer; transition: background var(--dur-fast); }
.op-row[data-try]:hover { background: #fafafa; }
.op-c { min-width: 0; padding-right: 12px; }
.op-c--time { color: var(--color-text-secondary); }
.op-c--status { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.op-td--none { color: var(--gray-400); }
.op-table--ov .op-tr, .op-table--aov .op-tr { grid-template-columns: 190px minmax(150px, 250px) 130px minmax(0, 1fr) 168px; }
.op-table--hi .op-tr { grid-template-columns: 120px 150px 150px 170px minmax(0, 1fr) 168px; }
.op-table--ahi .op-tr { grid-template-columns: 120px 140px 150px 190px minmax(0, 1fr) 168px; }
.op-tr--head > :last-child { text-align: right; white-space: nowrap; }
.op-thumbs { display: flex; gap: 8px; justify-content: flex-end; }
.op-c--thumbs { padding-right: 0; }
.op-empty { color: var(--color-text-secondary); padding: 40px 0; text-align: center; }
.op-hist__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.op-hist__all { font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; color: var(--color-text-secondary); text-decoration: none; white-space: nowrap; }
.op-hist__all:hover { color: var(--color-text-primary); }

/* ---------- постраничный вывод ---------- */
.op-pager { display: flex; align-items: center; gap: 4px; }
.op-pg { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; font-size: var(--ui-label-size); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-primary); }
.op-pg.is-on { background: var(--gray-950); color: #fff; }
.op-pg--gap { cursor: default; }
.op-pg:not(.is-on):not(.op-pg--gap):hover { background: rgba(24, 24, 27, 0.06); }
.op-pager .op-pg:first-child, .op-pager .op-pg:last-child { background: #fff; }
.op-pg:disabled { opacity: 0.4; cursor: default; }

/* ---------- оверлеи ---------- */
body.op-lock { overflow: hidden; }
.op-ov { position: fixed; inset: 0; z-index: 80; background: rgba(24, 24, 27, 0.45); display: flex; }
.op-ov--modal { align-items: center; justify-content: center; padding: 24px; }
.op-ov--drawer { justify-content: flex-end; }
.op-ov__box { background: var(--color-bg-card); box-shadow: var(--shadow-popup); max-height: 100%; overflow-y: auto; }
.op-ov--modal .op-ov__box { width: 100%; max-width: 560px; border-radius: 28px; padding: 32px; max-height: calc(100vh - 48px); }
.op-ov--drawer .op-ov__box { width: 480px; max-width: 100%; height: 100%; padding: 24px; }
.op-x { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--gray-100); display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* ---------- уведомления ---------- */
.op-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100; background: var(--gray-950); color: #fff; border-radius: var(--radius-full);
  padding: 12px 22px 12px 14px; font-size: var(--body-regular-size); line-height: 24px; opacity: 0; pointer-events: none; transition: opacity var(--dur-medium);
  max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 12px;
}
.op-toast.is-on { opacity: 1; }
.op-toast:not(:has(.op-toast__ok)) { padding-left: 22px; }
.op-toast__ok, .op-reportpill__ok { width: 24px; height: 24px; border-radius: 50%; background: var(--color-accent); display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* ---------- подсказка «В демо недоступно» ---------- */
[data-demo-off] { position: relative; }
[data-demo-off]::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  background: var(--gray-950); color: #fff; font-size: var(--body-caption-size); line-height: var(--body-caption-line-height); font-weight: 400; font-style: normal;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none; display: none; z-index: 40;
}
/* display:none, а не opacity:0 — невидимая подсказка иначе растягивает страницу вправо */
[data-demo-off]:hover::after, [data-demo-off]:focus-visible::after { display: block; transform: translateX(-50%); }
[data-demo-off][data-below]::after { bottom: auto; top: calc(100% + 8px); left: auto; right: 0; transform: translateY(-4px); }
[data-demo-off][data-below]:hover::after, [data-demo-off][data-below]:focus-visible::after { transform: none; }

/* ---------- график ---------- */
.op-chart { display: flex; flex-direction: column; position: relative; }
.op-chart__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.op-chart__total { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.op-chart__ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.op-chart__body { position: relative; margin-top: 28px; height: 310px; }
.op-plot { position: absolute; inset: 0; }
.op-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.op-plot .bar { fill: var(--gray-200); cursor: pointer; transition: fill var(--dur-fast) var(--ease-standard); }
.op-plot .bar.is-on { fill: var(--gray-950); }
.op-plot text { font-family: var(--font-text); font-size: 12px; fill: var(--color-text-secondary); }
.op-tip { position: absolute; pointer-events: none; z-index: 2; background: var(--gray-950); border-radius: 10px; padding: 8px 12px; white-space: nowrap; transform: translateX(-50%); opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
.op-tip.is-on { opacity: 1; }
.op-tip span { display: block; font-size: var(--body-caption-size); line-height: var(--body-caption-line-height); color: rgba(255, 255, 255, 0.6); }
.op-tip b { display: block; font-size: var(--ui-button-small-size); line-height: var(--ui-button-small-line-height); font-weight: 600; color: #fff; }

/* ---------- формы (только просмотр и локальный ввод) ---------- */
.op-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.op-label { font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 500; }
.op-hint { font-size: var(--body-caption-size); line-height: var(--body-caption-line-height); color: var(--color-text-secondary); }
.op-input { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; border-radius: 12px; background: var(--gray-100); min-width: 0; }
.op-input--sp { justify-content: space-between; }
.op-in { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; height: 52px; font-size: var(--body-regular-size); outline: none; }
.op-in::placeholder { color: var(--gray-500); opacity: 0.8; }
.op-input:focus-within { box-shadow: 0 0 0 2px var(--gray-950); }
.op-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.op-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.op-u { text-decoration: underline; text-underline-position: from-font; }
.op-link-b { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; font-size: var(--ui-label-size); line-height: var(--ui-label-line-height); font-weight: 600; }
.op-link { background: none; border: 0; padding: 0; text-align: left; }
.op-link--b { font-weight: 600; font-size: var(--ui-label-size); }
