/*
 * Личный кабинет Vin-Scan (docs/Кабинет.md): общие стили страниц. Системные шрифты, без внешних ресурсов (M-11).
 * Встроенных стилей и скриптов на страницах нет: CSP сервера их не пропускает (cabinet/pages.ts).
 * Акцент — тот же синий, что в виджете (apps/widget/src/styles.ts).
 */
:root {
  --accent: #1d5fd1;
  --accent-dark: #174fb0;
  --accent-light: #eef3fd;
  --text: #1c2530;
  --muted: #5d6b7b;
  --border: #dde5ec;
  --bg: #f3f6f9;
  --surface: #fff;
  --error: #b42318;
  --error-bg: #fdeceb;
  --ok: #17532a;
  --ok-bg: #e8f5ec;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  font-size: 15px;
  line-height: 22px;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
}

h1 {
  font-size: 24px;
  line-height: 32px;
  margin: 0 0 8px;
}

h2 {
  font-size: 18px;
  line-height: 26px;
  margin: 0 0 16px;
}

[hidden] {
  display: none !important;
}

/* Шапка */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.2px;
}

.logo span {
  color: var(--accent);
}

.menu {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.menu a,
.menu .soon {
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
}

.menu a[aria-current='page'] {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.menu .soon {
  cursor: default;
}

.menu .soon small {
  font-size: 11px;
}

.balance {
  font-weight: 600;
  white-space: nowrap;
}

.balance small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  line-height: 14px;
  color: var(--muted);
}

/* Содержимое */
.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.auth {
  max-width: 440px;
  margin: 48px auto;
  padding: 0 16px;
}

.auth .logo {
  display: block;
  text-align: center;
  font-size: 22px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.lead {
  color: var(--muted);
  margin: 0 0 20px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.grid .wide {
  grid-column: 1 / -1;
}

.field {
  margin-bottom: 16px;
}

.field label,
.field .label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.field .hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
  margin-top: 4px;
}

input[type='text'],
input[type='email'],
input[type='tel'],
input[type='password'],
input[type='url'],
textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  /* 16px — без автоувеличения страницы в Safari на iPhone. */
  font-size: 16px;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

input[readonly] {
  background: var(--bg);
  color: var(--muted);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
  font-size: 14px;
}

.check input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--accent);
}

.btn {
  display: inline-block;
  padding: 11px 20px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--accent-dark);
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn.secondary {
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
}

.btn.link {
  padding: 4px 0;
  color: var(--accent);
  background: none;
  font-weight: 500;
}

.btn.full {
  width: 100%;
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.form-error,
.form-ok {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 16px;
  font-size: 14px;
}

.form-error {
  color: var(--error);
  background: var(--error-bg);
}

.form-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.below {
  text-align: center;
  margin-top: 16px;
  color: var(--muted);
}

/* Ловушка для ботов: вне экрана, недоступна с клавиатуры и экранному диктору. */
.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.captcha {
  min-height: 100px;
  margin-bottom: 16px;
}

/* Телефоны 1-5 */
.phones .row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.phones .row .btn {
  flex: none;
}

/* Подсказки DaData */
.suggest {
  position: relative;
}

.suggest ul {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
}

.suggest li button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font: inherit;
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.suggest li button:hover,
.suggest li button:focus {
  background: var(--accent-light);
}

.suggest li small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.counter {
  float: right;
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 0 16px 24px;
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

  .auth {
    margin: 24px auto;
  }

  .top-inner {
    gap: 8px 16px;
  }

  .menu {
    order: 3;
    flex-basis: 100%;
  }

  .balance {
    margin-left: auto;
  }
}

.spaced {
  margin-top: 16px;
}

/* Виджеты: список, статусы, вкладки (widgets.html) */
select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.page-head h1,
.page-head h2 {
  margin: 0;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 560px;
}

.cards {
  display: grid;
  gap: 16px;
}

.shop-card .lead {
  margin: 4px 0 16px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.working {
  color: var(--ok);
  background: var(--ok-bg);
}

.badge.disabled {
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
}

.badge.pending_abcp {
  color: #7a4a00;
  background: #fff4e0;
}

.tabs {
  display: flex;
  gap: 4px;
  margin: 8px 0 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.tabs button[aria-selected='true'] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.hours {
  display: grid;
  gap: 6px;
}

.hours-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hours-row .day {
  width: 28px;
  font-weight: 600;
}

.hours-row input[type='time'] {
  padding: 6px 8px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.hours-row .check {
  margin: 0;
}

.checks {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.checks li {
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
}

.checks li.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.checks li.fail {
  color: var(--error);
  background: var(--error-bg);
}

.checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 16px;
}

.color-field .row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-field input[type='color'] {
  width: 56px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

pre.code {
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.install {
  margin: 16px 0 0;
  color: var(--muted);
}

.install.ok {
  color: var(--ok);
}

/* Предпросмотр виджета (fixed в углу) не закрывает кнопки формы внизу страницы. */
.look {
  padding-bottom: 120px;
}

@media (max-width: 640px) {
  .inline-form {
    flex-direction: column;
    max-width: none;
  }
}

/* На широком экране форма вида не уходит под окно предпросмотра (оно в правом нижнем углу, до 576 px). */
@media (min-width: 1100px) {
  .tab-panel.look {
    padding-right: 420px;
  }
}

/* Статистика (stats.html, docs/Кабинет.md, раздел 14). Цвета графиков: синий акцент — вопросы, зелёный — ответы. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.stats-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.stats-controls select {
  width: auto;
  min-width: 180px;
  max-width: 260px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segmented button {
  border: 0;
  background: none;
  padding: 8px 12px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--border);
}

.segmented button[aria-pressed='true'] {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.stats-gauges,
.stats-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0 16px;
}

.stats-gauges .card,
.stats-numbers .card {
  margin-bottom: 16px;
}

.gauge {
  text-align: center;
}

.gauge h2 {
  font-size: 15px;
  line-height: 20px;
  margin-bottom: 8px;
}

.gauge svg {
  width: 100%;
  max-width: 220px;
  display: block;
  margin: 0 auto;
}

.gauge-value {
  font-size: 30px;
  font-weight: 700;
  fill: var(--text);
}

.gauge-caption {
  color: var(--muted);
  margin: 4px 0 8px;
  font-size: 14px;
}

.level {
  display: inline-block;
  font-size: 12px;
  line-height: 18px;
  padding: 0 8px;
  border-radius: 9px;
}

.level.low {
  background: #fdeceb;
  color: #b42318;
}

.level.mid {
  background: #fef4e6;
  color: #93500b;
}

.level.good {
  background: #e8f5ec;
  color: #17532a;
}

.number {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.number b {
  font-size: 28px;
  line-height: 34px;
}

.number span {
  color: var(--muted);
}

.stats-rings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 16px;
}

.ring svg {
  width: 140px;
  height: 140px;
  display: block;
  margin: 0 auto 12px;
}

.ring-total {
  font-size: 20px;
  font-weight: 700;
  fill: var(--text);
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.legend li span {
  flex: 1;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.dot.q {
  background: var(--accent);
}

.dot.a {
  background: #12b76a;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--muted);
  margin: -8px 0 8px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

svg.daily {
  width: 100%;
  height: auto;
  display: block;
}

.daily .axis line {
  stroke: #e4e9ef;
}

.daily text {
  font-size: 11px;
  fill: var(--muted);
}

.daily .bar.q {
  fill: var(--accent);
}

.daily .bar.a {
  fill: #12b76a;
}

.daily .hit {
  fill: transparent;
}

.daily g:hover .hit {
  fill: rgba(29, 95, 209, 0.06);
}

.hbars {
  display: grid;
  gap: 10px;
}

.hbar {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr auto auto;
  align-items: center;
  gap: 12px;
}

.hbar .name {
  font-size: 14px;
}

.hbar .track {
  height: 12px;
  background: #eef2f6;
  border-radius: 6px;
  overflow: hidden;
}

.hbar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.hbar b {
  min-width: 40px;
  text-align: right;
}

.hbar .conv {
  color: var(--muted);
  min-width: 44px;
  text-align: right;
}

.stats-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.order-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.order-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.order-row div {
  display: flex;
  flex-direction: column;
}

.order-row b {
  font-size: 18px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .stats-gauges,
  .stats-numbers {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-rings,
  .stats-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .stats-gauges,
  .stats-numbers {
    gap: 0 8px;
  }

  .stats-gauges .card,
  .stats-numbers .card {
    margin-bottom: 8px;
    padding: 12px;
  }

  .gauge-value {
    font-size: 34px;
  }

  .number b {
    font-size: 22px;
  }

  .stats-controls {
    width: 100%;
  }

  .stats-controls select {
    flex: 1 1 100%;
    max-width: none;
  }

  .hbar {
    grid-template-columns: 1fr auto auto;
    gap: 4px 8px;
  }

  .hbar .track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
