/* Admin shell — academic, dense, multi-tab.
   Дополняет style.css и expert.css (header, modal, btn-*, sessions-table). */

body.admin-app main {
  display: block;
  max-width: 1440px;
  padding: var(--sp-4) var(--sp-5);
}
/* Защита от переопределения [hidden] более специфичным display:
   когда showForbidden() ставит admin-main hidden, оно ДОЛЖНО скрываться. */
body.admin-app main[hidden],
body.admin-app .admin-tab[hidden] {
  display: none !important;
}

/* ─── Header / nav ─── */
.admin-header {
  display: grid;
  grid-template-areas: "brand navigation actions";
  grid-template-columns: minmax(250px, 0.8fr) minmax(600px, 2.8fr) minmax(340px, 1fr);
  align-items: center;
  gap: var(--sp-4) var(--sp-5);
  padding: var(--sp-3) clamp(var(--sp-4), 2vw, var(--sp-6));
}
.admin-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
}
.admin-brand .site-home-logo {
  font-size: var(--fs-md);
  line-height: 1;
}
.admin-brand .header-title {
  flex: 0 1 auto;
}
.admin-navigation {
  grid-area: navigation;
  min-width: 0;
}
.admin-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  min-width: 0;
  row-gap: 4px;
}
.admin-nav a {
  color: rgba(255,255,255,0.88);
  text-decoration: none;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.admin-nav a:hover { background: rgba(255,255,255,0.12); color: white; }
.admin-nav a.active {
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: 600;
}
.admin-workspaces {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid rgba(255,255,255,0.16);
}
.admin-workspace-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.82);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.admin-workspace-link:hover {
  color: white;
  background: rgba(255,255,255,0.12);
}
.admin-workspace-link__icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.admin-nav a:focus-visible,
.admin-workspace-link:focus-visible,
.admin-brand a:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* ─── Компактный user-chip в админке ─── */
/* На главной шапка крупная (с emoji), в админке нужна узкая полоска,
   чтобы оставить место для навигации. Ужимаем chip и убираем
   избыточные header-link иконки. */
.admin-app #user-chip {
  max-width: 260px;             /* +badge — нужно больше места */
  padding: 3px 3px 3px 10px;
  font-size: var(--fs-xs);
  gap: var(--sp-2);
}
.admin-app #user-chip-logout {
  width: 20px;
  height: 20px;
  font-size: 11px;
}
/* Role badge: компактный чип, цвет зависит от роли — admin зелёный,
   expert синий, остальные серые. Помогает понять «почему доступ ограничен». */
.admin-app .user-chip-role {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(255,255,255,0.18);
  color: white;
  white-space: nowrap;
}
.admin-app .user-chip-role[data-role="admin"]   { background: rgba(46, 160, 67, 0.78); }
.admin-app .user-chip-role[data-role="expert"]  { background: rgba(64, 120, 192, 0.78); }
.admin-app .user-chip-role[data-role="student"] { background: rgba(120, 120, 120, 0.55); }
/* Контекстная плашка «вы вошли как X» внутри login-модалки (заменяет
   старую полноэкранную карточку «Доступ ограничен»). */
.login-current-account {
  background: var(--color-bg-accent, rgba(217, 119, 6, 0.08));
  border: 1px solid var(--color-warning, #d97706);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin: 0 0 var(--sp-3) 0;
  line-height: 1.5;
}
.login-current-account b { color: var(--color-text); }
.admin-app .header-actions {
  grid-area: actions;
  gap: var(--sp-2);
  flex-wrap: nowrap;
  flex-shrink: 0;
  align-items: center;
  justify-self: end;
}
.admin-app .header-title h1 {
  font-size: var(--fs-lg);
}
.admin-app #header-subtitle {
  font-size: var(--fs-xs);
  opacity: 0.82;
}
/* Фиксированная стилистика для language-switcher (profile-locale.js):
   у select в шапке должен быть нормальный отступ от соседних элементов,
   максимальная ширина — чтобы длинные имена не растягивали шапку. */
.admin-app #profile-locale-switcher {
  max-width: 160px;
  margin-right: 0 !important;  /* gap у header-actions достаточно */
  flex-shrink: 0;
}

@media (max-width: 1650px) {
  .admin-header {
    grid-template-areas:
      "brand actions"
      "navigation navigation";
    grid-template-columns: minmax(240px, 1fr) auto;
  }
}
@media (max-width: 980px) {
  .admin-header {
    grid-template-areas:
      "brand"
      "actions"
      "navigation";
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }
  .admin-app .header-actions {
    justify-self: stretch;
    justify-content: flex-end;
  }
}
@media (max-width: 680px) {
  .admin-header {
    padding: var(--sp-3) var(--sp-4);
  }
  .admin-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: var(--sp-1);
    scrollbar-width: thin;
  }
  .admin-nav a {
    flex: 0 0 auto;
  }
  .admin-workspace-link {
    flex: 1 1 calc(50% - 3px);
    justify-content: space-between;
  }
  .admin-app .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
@media (max-width: 420px) {
  .admin-brand {
    align-items: flex-start;
  }
  .admin-workspace-link {
    flex-basis: 100%;
  }
}

/* ─── Filters ─── */
.filters {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
  margin-left: auto;
}
.filters select,
.filters input,
.toolbar select,
.toolbar input {
  padding: 6px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-family: inherit;
  background: var(--color-surface);
}
.filters input[type="search"] { min-width: 220px; }
.filters input[type="date"] { font-family: var(--font-mono); }

/* ─── Tables ─── */
.admin-table {
  font-size: var(--fs-sm);
}
.admin-table th { font-size: 11px; }
.admin-table .has-expert { background: rgba(22, 101, 52, 0.04); }
.muted-sm { font-size: var(--fs-xs); color: var(--color-text-muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.status {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  display: inline-block;
}
.status-completed { background: var(--color-success-bg); color: var(--color-success); }
.status-in_progress { background: var(--color-warning-bg); color: var(--color-warning); }
.status-abandoned { background: var(--color-danger-bg); color: var(--color-danger); }

.role-pill {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.role-pill.role-student { background: var(--color-primary-soft); color: var(--color-primary); }
.role-pill.role-expert { background: rgba(180, 83, 9, 0.14); color: var(--color-warning); }
.role-pill.role-admin { background: rgba(22, 101, 52, 0.14); color: var(--color-success); }

.btn-sm { padding: 4px 10px; font-size: var(--fs-xs); min-height: 28px; margin-right: 4px; }

/* ─── Detail subtabs ─── */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin: 0 0 var(--sp-4) 0;
  flex-wrap: wrap;
}
.dtab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 16px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: -2px;
}
.dtab:hover { color: var(--color-primary); }
.dtab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.dpane { display: none; }
.dpane.active { display: block; }

.report-iframe-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: calc(100vh - 280px);
  min-height: 500px;
}
#report-iframe, #coach-frame { width: 100%; height: 100%; border: none; background: white; }

/* ─── Side-by-side judgments table ─── */
.rubric-card-compare {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.rubric-card-compare h3 {
  margin: 0 0 var(--sp-1) 0;
  color: var(--color-primary);
  font-size: var(--fs-md);
}
.rubric-card-compare .hint {
  margin: 0 0 var(--sp-3) 0;
  font-size: var(--fs-xs);
}
.diverge-sample {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  background: rgba(180, 83, 9, 0.25);
  border: 1px solid var(--color-warning);
  vertical-align: middle;
  margin: 0 4px;
}

.cmp-table-wrap {
  overflow-x: auto;
}
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-xs);
  min-width: 720px;
}
.cmp-table th,
.cmp-table td {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  vertical-align: top;
}
.cmp-table thead th {
  background: var(--color-surface-2);
  font-weight: 600;
  text-align: center;
  color: var(--color-text);
}
.cmp-table thead th:first-child { text-align: left; min-width: 240px; }
.cmp-table .row-summary-label {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
}
.cmp-table .cell-summary {
  background: var(--color-primary-soft);
  text-align: center;
  min-width: 160px;
}
.cmp-table .cell-summary-text {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
  text-align: left;
  font-style: italic;
}
.cmp-table .cell-total {
  font-weight: 700;
  font-size: var(--fs-md);
}
.cmp-table .cell-pct {
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  font-size: 11px;
}
.cmp-table .td-item {
  background: var(--color-bg);
  min-width: 240px;
}
.cmp-table .item-id {
  font-family: var(--font-mono);
  color: var(--color-text-subtle);
  font-size: 11px;
}
.cmp-table .item-section {
  margin-bottom: 2px;
}
.cmp-table .item-text { color: var(--color-text); font-size: var(--fs-xs); }
.cmp-table .cell-score {
  text-align: center;
  min-width: 140px;
}
.cmp-table .cell-score.diverge {
  background: rgba(180, 83, 9, 0.10);
  border-color: var(--color-warning);
}
.cmp-table .score-num {
  font-size: var(--fs-md);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-text);
}
.cmp-table .score-rat {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
  text-align: left;
  line-height: 1.4;
}
.cmp-table .score-ev {
  font-size: 10px;
  color: var(--color-text-subtle);
  font-style: italic;
  margin-top: 3px;
  text-align: left;
}
.cmp-table .cell-callouts {
  background: var(--color-bg);
  vertical-align: top;
}
.cmp-table .callout-good,
.cmp-table .callout-improve {
  font-size: 11px;
  margin-bottom: 6px;
  padding: 6px 8px;
  border-radius: 4px;
}
.cmp-table .callout-good { background: var(--color-success-bg); color: var(--color-success); }
.cmp-table .callout-improve { background: var(--color-warning-bg); color: var(--color-warning); }
.cmp-table .callout-good ul,
.cmp-table .callout-improve ul {
  margin: 4px 0 0 16px;
  padding: 0;
}

/* ─── Reflection card ─── */
.reflection-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.reflection-card .reflection-text {
  background: var(--color-surface-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  margin-top: 4px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
}

/* ─── Scenario full ─── */
#scenario-full-wrap section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
}
#scenario-full-wrap h4 {
  margin: 0 0 var(--sp-2) 0;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
}
.obj-dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 4px var(--sp-3);
  margin: 0;
  font-size: var(--fs-sm);
}
.obj-dl dt {
  color: var(--color-text-muted);
  font-weight: 500;
}
.obj-dl dd { margin: 0; color: var(--color-text); }
.scenario-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--sp-3);
}
.xml-raw {
  background: var(--color-surface-2);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: 11px;
  overflow-x: auto;
  max-height: 400px;
}
.warn-banner {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-left: 3px solid var(--color-warning);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-sm);
}

/* ─── Meta JSON ─── */
#meta-json {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-height: 70vh;
  overflow-y: auto;
}

/* ─── Invites tab ─── */
.invites-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
@media (max-width: 900px) {
  .invites-grid { grid-template-columns: 1fr; }
}
#bulk-textarea {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  resize: vertical;
}
.upload-btn {
  display: inline-block;
  background: var(--color-surface);
  border: 1px dashed var(--color-primary);
  color: var(--color-primary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.upload-btn:hover { background: var(--color-primary-soft); }

.form-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.form-row .label {
  flex: 0 0 auto;
  min-width: 80px;
  font-size: var(--fs-sm);
  color: var(--color-text);
}
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="number"],
.form-row input[type="password"],
.form-row select {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
/* Стопка «подпись над полем» — для высоких контролов (textarea). */
.form-row--block {
  flex-direction: column;
  align-items: stretch;
}
.form-row--block .label {
  min-width: 0;
  margin-bottom: var(--sp-1);
}
.form-row--block textarea {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  resize: vertical;
  box-sizing: border-box;
}
/* Карточка организации (#org-card-modal): секции «Основное» / «Реквизиты». */
.oc-section + .oc-section {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--color-border);
}
.oc-section-title {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}
.oc-section .form-row .label {
  min-width: 160px;
}

/* Отдельные блоки настроек (почта и т.п.) под основной панелью «Настройки». */
.settings-section {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--color-border);
}
.muted { color: var(--color-text-muted); font-size: var(--fs-xs); margin: 0 0 var(--sp-2) 0; }

.result-summary {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-3);
}
.badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.badge-ok { background: var(--color-success-bg); color: var(--color-success); }
.badge-err { background: var(--color-danger-bg); color: var(--color-danger); }

.link-inline {
  display: flex;
  gap: 4px;
  align-items: center;
}
.link-inline input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}
.error-text { color: var(--color-danger); font-size: var(--fs-xs); }

/* ─── Link copy modal ─── */
.link-box {
  display: flex;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
}
.link-box input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  background: var(--color-surface-2);
}

/* ─── Transcript styles (reuse) ─── */
#full-transcript-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-sm);
  max-height: 75vh;
  overflow-y: auto;
}
#full-transcript-wrap .t-turn { padding: 6px 10px; border-radius: var(--radius-sm); }
#full-transcript-wrap .t-doc { background: var(--color-primary-soft); }
#full-transcript-wrap .t-pat { background: var(--color-surface-2); }
#full-transcript-wrap .t-speaker { font-weight: 600; margin-right: 4px; }
#full-transcript-wrap .t-doc .t-speaker { color: var(--color-primary); }
#full-transcript-wrap .t-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-subtle);
  margin-left: 6px;
}
#full-transcript-wrap .t-internal {
  font-size: 11px;
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: 2px;
}

/* ─── Timings tab (отладочная вкладка) ─── */
.timings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.timings-summary {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: var(--sp-4);
}
.ts-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  min-width: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.ts-card-h {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ts-card-v {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-text);
}
.ts-card-v.ts-bad { color: var(--color-danger); }
.ts-card-sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-weight: 400;
  margin-left: 6px;
  font-family: var(--font-mono);
}
.ts-stats {
  flex: 1;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-width: 360px;
}
.ts-stats th,
.ts-stats td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: right;
}
.ts-stats th:first-child,
.ts-stats td:first-child { text-align: left; }
.ts-stats thead th {
  background: var(--color-surface-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
}
.ts-stats tbody tr:last-child td { border-bottom: none; }
.ts-row-judge td {
  background: var(--color-primary-soft);
  border-top: 1px solid var(--color-border);
}
.ts-h {
  margin: var(--sp-4) 0 var(--sp-2) 0;
  font-size: var(--fs-md);
  color: var(--color-text);
}
.timings-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.timings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.timings-table th,
.timings-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--color-border);
  text-align: right;
  vertical-align: top;
}
.timings-table th:first-child,
.timings-table th:nth-child(2),
.timings-table td:first-child,
.timings-table td:nth-child(2) { text-align: left; }
.timings-table thead th {
  background: var(--color-surface-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
  position: sticky; top: 0; z-index: 1;
}
.timings-table tbody tr:hover { background: var(--color-bg); }
.timings-table tbody tr:last-child td { border-bottom: none; }
.timings-table .td-error {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-danger);
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-word;
}
.timings-table .tr-error { background: rgba(180, 33, 33, 0.05); }

/* Тех-события (Задача 13): пейн деталей сессии, client/lib/admin-techevents.js */
.te-section { margin-bottom: var(--sp-4); }
.te-section-title {
  margin: 0 0 var(--sp-2) 0;
  font-size: var(--fs-md);
  color: var(--color-text);
}
.te-empty {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin: 0;
}
.te-events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.te-events-table th,
.te-events-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}
.te-events-table thead th {
  background: var(--color-surface-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
}
.te-events-table tbody tr:last-child td { border-bottom: none; }
.te-events-table tbody tr:hover { background: var(--color-bg); }
.te-artifacts-count {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  color: var(--color-text);
  margin: 0;
}
.te-artifact-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--sp-2);
}
.te-artifact-chip {
  display: inline-block;
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
  padding: 1px 9px;
  font-size: 12px;
  color: var(--color-text-muted);
}
.cleanup-inline {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-left: 6px;
  font-family: var(--font-mono);
}
.tcell-orange {
  background: rgba(180, 83, 9, 0.14);
  color: var(--color-warning);
  font-weight: 600;
}
.tcell-red {
  background: rgba(180, 33, 33, 0.18);
  color: var(--color-danger);
  font-weight: 700;
}

/* ─── Toast (повторно с expert.css на случай если не загружен) ─── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-success);
  color: white;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--color-danger); }

/* ─── Translations admin (i18n) ─── */
.tr-table { border-collapse: collapse; font-size: 13px; }
.tr-table thead th {
  background: var(--color-surface-2);
  border-bottom: 2px solid var(--color-border);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.tr-table thead th.lang-col {
  background: linear-gradient(180deg, #e0f2fe 0%, #f0f9ff 100%);
  color: #0c4a6e;
  min-width: 200px;
  position: relative;
}
.tr-table thead th.lang-col .flag { font-size: 18px; margin-right: 6px; }
.tr-table thead th .lang-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.tr-table thead th .lang-action-btn {
  background: rgba(255,255,255,0.5);
  border: 1px solid #bae6fd;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  cursor: pointer;
  color: #0c4a6e;
}
.tr-table thead th .lang-action-btn:hover {
  background: white;
  color: #075985;
}
.tr-table tbody td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.tr-table tbody tr:hover { background: rgba(2, 132, 199, 0.04); }
.tr-table .key-col {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  max-width: 280px;
  overflow-wrap: break-word;
  background: var(--color-surface-2);
  position: sticky;
  left: 0;
  z-index: 0;
}
.tr-table .ns-col {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  font-weight: 700;
  padding-right: 6px;
}
.tr-table tbody td textarea {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 4px;
  resize: vertical;
  min-height: 28px;
  line-height: 1.35;
}
.tr-table tbody td textarea:hover { border-color: var(--color-border); background: white; }
.tr-table tbody td textarea:focus {
  outline: none;
  border-color: #0284c7;
  background: white;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}
.tr-table tbody td.cell-empty textarea { background: rgba(180, 33, 33, 0.05); }
.tr-table tbody td.cell-saved-source-ai::after {
  content: "AI";
  position: absolute;
  font-size: 8px;
  background: #f59e0b;
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: -22px;
  margin-top: 2px;
}
.tr-table tbody td.cell-unapproved {
  border-left: 3px solid var(--color-warning);
}
.tr-table tbody td.cell-modified {
  background: rgba(34, 139, 34, 0.05);
}
.tr-table tbody td.cell-modified::before {
  content: "● ";
  color: var(--color-success);
  font-size: 12px;
}
.tr-table .delete-locale-btn {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #dc2626;
}
.tr-table .delete-locale-btn:hover { background: rgba(220, 38, 38, 0.15); }


/* ─── LLM diagnostics panel (Test button results) ───────────────── */
.diag-panel {
  margin: 0 0 var(--sp-3) 0;
  padding: var(--sp-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}
.diag-panel-header {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-weight: 600;
}
.diag-panel-summary {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-left: auto;
}
.diag-panel-rows {
  display: grid; gap: 6px;
}
.diag-row {
  display: grid;
  grid-template-columns: 28px 160px 80px 1fr;
  gap: var(--sp-2); align-items: center;
  padding: 8px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
.diag-row .diag-icon { font-size: 18px; text-align: center; }
.diag-row .diag-name { font-weight: 600; font-family: var(--font-mono); }
.diag-row .diag-latency {
  font-size: var(--fs-xs); color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.diag-row .diag-detail { color: var(--color-text-muted); font-size: var(--fs-xs); line-height: 1.3; word-break: break-word; }
.diag-row.status-ok   { border-left: 4px solid #16a34a; }
.diag-row.status-warn { border-left: 4px solid #d97706; }
.diag-row.status-fail { border-left: 4px solid #dc2626; }
.diag-row.status-skip { border-left: 4px solid #9ca3af; }
.diag-row.status-running { border-left: 4px solid #156082; opacity: 0.7; }
.diag-row .diag-retest {
  background: none; border: none;
  color: var(--color-primary, #156082);
  cursor: pointer;
  font-size: var(--fs-xs);
  padding: 2px 6px;
  border-radius: 4px;
}
.diag-row .diag-retest:hover { background: rgba(21, 96, 130, 0.08); }


/* AI diagnostics: groups (LLM / TTS / ASR) */
.diag-group { margin-top: var(--sp-3); }
.diag-group:first-child { margin-top: var(--sp-2); }
.diag-group-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.diag-group-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--color-text-subtle);
}

/* ─── Вкладка «Звук»: композер резервной ASR-цепочки ─── */
#sound-chain-list { display: flex; flex-direction: column; gap: 2px; margin: var(--sp-2) 0; max-width: 560px; }
#sound-chain-list .chain-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
#sound-chain-list .chain-toggle { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }
#sound-chain-list .chain-note { color: var(--color-warning, #b45309); font-size: var(--fs-xs); }
#sound-chain-list .chain-move { margin-left: auto; display: flex; gap: 4px; }
#sound-chain-list .chain-move button { padding: 2px 8px; cursor: pointer; }
#sound-chain-list .chain-move button:disabled { opacity: 0.4; cursor: default; }
#sound-chain-status.chain-status-ok { color: var(--color-success); }
#sound-chain-status.chain-status-warn { color: var(--color-warning, #b45309); }

/* ─── Вкладка «Звук»: студия голоса (перенос standalone /voice-studio) ───
   Тёмная self-contained панель — стили портированы из voice-studio.html,
   заскоуплены под #sound-voice-studio-body. */
#sound-voice-studio-body .vs-embed {
  display: grid;
  grid-template-columns: 260px 1fr 320px;
  min-height: 480px;
  max-height: 72vh;
  background: #1a2332;
  color: #e0e8f0;
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  font-family: var(--font-base);
}
@media (max-width: 1100px) {
  #sound-voice-studio-body .vs-embed { grid-template-columns: 1fr; max-height: none; }
}

/* Левая панель — голоса. height (не max-height) нужен, чтобы grid-stretch не
   растягивал панель по контенту (60+ голосов) — иначе overflow-y:auto не
   от чего скроллить, и список продавливает всю страницу вниз. */
#sound-voice-studio-body .voices-panel {
  background: #0e1822;
  border-right: 1px solid #2a3444;
  height: 72vh;
  overflow-y: auto;
  padding: var(--sp-3);
}
@media (max-width: 1100px) {
  #sound-voice-studio-body .voices-panel { height: 50vh; border-right: none; }
}
#sound-voice-studio-body .voices-panel h3,
#sound-voice-studio-body .test-panel h3,
#sound-voice-studio-body .controls-panel h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6c7d8e;
  margin: 0 0 var(--sp-2) 0;
  border: none;
  padding: 0;
}
#sound-voice-studio-body #voice-search {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  background: #131e2c;
  border: 1px solid #2a3444;
  color: #d8e1ea;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: var(--sp-2);
}
#sound-voice-studio-body #voice-search:focus { outline: none; border-color: #4a90e2; }
#sound-voice-studio-body #voice-provider-filter {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  background: #131e2c;
  border: 1px solid #2a3444;
  color: #d8e1ea;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: var(--sp-2);
}
#sound-voice-studio-body #voice-provider-filter:focus { outline: none; border-color: #4a90e2; }
#sound-voice-studio-body .backend-group { margin-bottom: var(--sp-3); }
#sound-voice-studio-body .backend-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4a6070;
  padding: 2px 0 4px 0;
  border-bottom: 1px solid #1d2d3d;
  margin-bottom: 4px;
}
#sound-voice-studio-body .voice-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #c0cfdc;
  margin: 2px 0;
  border: 1px solid transparent;
  transition: all 0.12s;
}
#sound-voice-studio-body .voice-item:hover { background: #1a2d3f; border-color: #2a3e52; }
#sound-voice-studio-body .voice-item.active {
  background: #1e3148;
  border-color: #4a90e2;
  color: #fff;
}
#sound-voice-studio-body .voice-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(74,144,226,0.2);
  color: #7ab0e0;
  white-space: nowrap;
}
#sound-voice-studio-body .voice-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Центральная панель — тест */
#sound-voice-studio-body .test-panel {
  padding: var(--sp-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
#sound-voice-studio-body #sel-voice {
  font-size: 15px;
  font-weight: 600;
  color: #e8f0f8;
  min-height: 22px;
  padding: 4px 0;
}
#sound-voice-studio-body #sel-voice.empty { color: #4a5e72; font-style: italic; font-weight: 400; }
#sound-voice-studio-body #test-text {
  width: 100%;
  box-sizing: border-box;
  background: #131e2c;
  border: 1px solid #2a3444;
  color: #d8e1ea;
  border-radius: 6px;
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
  min-height: 72px;
  font-family: var(--font-base);
}
#sound-voice-studio-body #test-text:focus { outline: none; border-color: #4a90e2; }
#sound-voice-studio-body .ctrl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  margin: 6px 0;
}
#sound-voice-studio-body .ctrl-row label { flex: 0 0 90px; color: #c0cfdc; margin: 0; }
#sound-voice-studio-body .ctrl-row select,
#sound-voice-studio-body .ctrl-row input[type=range] { flex: 1; }
#sound-voice-studio-body .ctrl-row select {
  background: #131e2c;
  border: 1px solid #2a3444;
  color: #d8e1ea;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}
#sound-voice-studio-body .ctrl-val {
  flex: 0 0 36px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #9bb0c5;
}
#sound-voice-studio-body #subst-hint {
  font-size: 12px;
  color: #e0a050;
  min-height: 18px;
  padding: 3px 0;
}
#sound-voice-studio-body .preview-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
#sound-voice-studio-body #btn-preview {
  padding: 9px 20px;
  background: #2563eb;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
#sound-voice-studio-body #btn-preview:hover { background: #1e4fc7; }
#sound-voice-studio-body #btn-preview:disabled { background: #2a3a50; color: #6c7d8e; cursor: not-allowed; }
#sound-voice-studio-body #preview-audio { max-width: 320px; height: 36px; }
#sound-voice-studio-body #status {
  font-size: 12px;
  color: #ff8b6b;
  min-height: 18px;
  padding: 2px 0;
}
#sound-voice-studio-body #status.ok { color: #6bcf7f; }

/* Правая панель — палитра + просодия */
#sound-voice-studio-body .controls-panel {
  background: #0e1822;
  border-left: 1px solid #2a3444;
  overflow-y: auto;
  padding: var(--sp-3);
}
#sound-voice-studio-body .controls-panel section { margin-bottom: var(--sp-4); }
#sound-voice-studio-body #palette-boxes { display: flex; flex-direction: column; gap: 4px; }
#sound-voice-studio-body .palette-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
}
#sound-voice-studio-body .palette-row:hover { background: #1a2d3f; }
#sound-voice-studio-body .palette-row input[type=checkbox] { margin: 0; }
#sound-voice-studio-body .palette-row label { cursor: pointer; flex: 1; color: #c0cfdc; margin: 0; }
#sound-voice-studio-body .hint {
  font-size: 11px;
  color: #4a6070;
  line-height: 1.4;
  margin-top: 4px;
}
#sound-voice-studio-body #pitch-hint { color: #e0a050; min-height: 0; }
#sound-voice-studio-body .actions {
  display: flex;
  gap: 8px;
  margin-top: var(--sp-3);
}
#sound-voice-studio-body .actions button {
  flex: 1;
  padding: 10px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #2a3444;
  background: #1a2332;
  color: #c0cfdc;
}
#sound-voice-studio-body .actions button.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
#sound-voice-studio-body .actions button:hover { background: #243245; }
#sound-voice-studio-body .actions button.primary:hover { background: #1e4fc7; }
