/* Экраны A1-04: поиск, клиенты, шаблоны, настройки. Только токены дизайн-системы. */

/* ---------- Поиск (командная строка) ---------- */
.cmd-form {
  margin: 0;
}

.cmd-results {
  margin-top: var(--s-2);
}

.cmd-results .cmd-list {
  margin-top: 0;
}

a.cmd-item {
  color: var(--text);
  text-decoration: none;
}

a.cmd-item:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  background: var(--surface-2);
}

.cmd-hit {
  min-height: 56px;
  padding-top: var(--s-2);
  padding-bottom: var(--s-2);
}

.cmd-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cmd-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cmd-sub {
  color: var(--text-2);
  font-size: var(--fs-14);
  overflow-wrap: anywhere;
}

.cmd-empty {
  padding: var(--s-2) var(--s-3);
}

/* ---------- Предпросмотр шаблонов ---------- */
.preview-box {
  padding: var(--s-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-1);
}

.preview-box .pre {
  overflow-wrap: anywhere;
}

.var {
  padding: 0 3px;
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 4px;
}

.var-missing {
  background: var(--warning-bg);
  color: var(--warning);
  outline: 1px dashed var(--warning);
}

.tpl-body {
  min-height: 180px;
}

.reply {
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-1);
}

/* ---------- Настройки ---------- */
fieldset.card {
  min-width: 0;
  margin: 0;
}

fieldset.card > legend {
  padding: 0 var(--s-2);
  font-size: var(--fs-18);
  font-weight: 700;
}

.check-chip {
  position: relative;
  display: inline-flex;
  min-width: var(--tap);
  min-height: var(--tap);
}

.check-chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.check-chip span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-1);
  font-weight: 600;
}

.check-chip input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--link);
}

.check-chip input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.reply-preview .cluster form,
form.cluster {
  margin: 0;
}

/* ---------- Отчёт по каналам и расходы (A1-08) ---------- */
.period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-3) 0;
}

.period-label {
  text-align: center;
}

.period-nav .btn {
  flex: none;
  white-space: nowrap;
}

.report-wrap {
  padding: 0;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.report-table th,
.report-table td {
  padding: var(--s-3);
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.report-table th[scope="col"] {
  white-space: nowrap;
  font-size: var(--fs-14);
  color: var(--text-2);
  font-weight: 600;
}

.report-table th[scope="row"],
.report-table thead th:first-child {
  text-align: left;
}

.report-table tfoot th,
.report-table tfoot td {
  font-weight: 700;
  border-bottom: 0;
}

.report-table td:not(:first-of-type) {
  white-space: nowrap;
}

.cell-sub {
  display: block;
  font-size: var(--fs-14);
  color: var(--text-2);
  font-weight: 400;
}

@media (max-width: 899px) {
  /* узкий экран: каждая строка - карточка «показатель: значение», без горизонтальной прокрутки */
  .report-table,
  .report-table tbody,
  .report-table tfoot,
  .report-table tr,
  .report-table th,
  .report-table td {
    display: block;
  }

  .report-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .report-table tr {
    padding: var(--s-3);
    border-bottom: 1px solid var(--border);
  }

  .report-table th[scope="row"] {
    padding: 0 0 var(--s-2);
    border: 0;
    font-size: var(--fs-18);
  }

  .report-table td {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-1) 0;
    border: 0;
  }

  .report-table td::before {
    content: attr(data-label);
    color: var(--text-2);
  }

  .report-table td::before {
    white-space: nowrap;
  }

  .cell-sub {
    flex: 1 0 100%;
    text-align: right;
    white-space: normal;
  }
}
