/* ───────────────────────────────────────────────────────────
   Marine Health · QA interface
   Dark theme, tokens from stat.marinehealth.asia (marine-web)
   ─────────────────────────────────────────────────────────── */

:root {
  --bg: #080b12;
  --card: #111827;
  --card-2: #0f1624;
  --border: #1e2740;
  --border-soft: rgba(30, 39, 64, 0.5);
  --accent: #3b82f6;
  --a2: #6366f1;
  --fg: #ffffff;
  --muted: #9ca3af;
  --muted-2: #6b7280;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: var(--accent);
}

/* ─── Base/reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; color: var(--fg); }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }
h4 { font-size: 0.9rem; }
p { margin: 0 0 0.5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 0.78rem; color: var(--muted); }

/* ─── Layout shell ──────────────────────────────────────── */
.container-fluid {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
}
main.container-fluid { padding-top: 20px; padding-bottom: 48px; }

/* ─── Header ────────────────────────────────────────────── */
.app-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 8px 0;
}
.app-header .container-fluid {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  width: 100%;
}
.app-header strong {
  font-family: 'Unbounded', 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--fg);
  white-space: nowrap;
}
/* ─── User profile chip ─────────────────────────────────── */
.user-chip {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  padding: 0;
  text-transform: uppercase;
}
.user-avatar:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.user-avatar:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  z-index: 200;
  overflow: hidden;
  animation: fadeIn 0.12s ease;
}
.user-menu-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.user-menu-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-email {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.user-menu-role {
  font-size: 0.7rem;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--fg);
  border: 0;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s;
}
.user-menu-item:hover,
.user-menu-item:focus-visible {
  background: var(--bg);
  outline: none;
}
.user-menu-item.danger { color: var(--danger); }

.user-menu-section {
  border-top: 1px solid var(--border-soft);
  padding: 4px 0;
}
.user-menu-health {
  border-top: 1px solid var(--border-soft);
  padding: 10px 16px;
  color: var(--muted);
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
  word-break: break-word;
}

/* ─── Tabs ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.tabs .tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.tabs .tab:hover {
  background: var(--bg);
  color: var(--fg);
}
.tabs .tab.active {
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
}

.tab-pane { display: none; }
.tab-pane.active {
  display: block;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ─── Filter cards ──────────────────────────────────────── */
.filters {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 0.9rem;
}
.filters .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  align-items: end;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 500;
  margin: 0;
}
.filters small {
  display: block;
  margin-top: 0.65rem;
  color: var(--muted);
}

.meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.4rem 0 0.6rem;
}

/* ─── Inputs / selects / textareas ──────────────────────── */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select[multiple] { padding: 0.3rem; }
select option { background: var(--card); color: var(--fg); }
textarea { resize: vertical; min-height: 60px; line-height: 1.45; }

label.checkbox {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
label.checkbox input[type="checkbox"] {
  width: auto;
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

/* ─── Buttons ───────────────────────────────────────────── */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--accent), var(--a2));
  color: #fff;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
}
button:hover:not(:disabled) { opacity: 0.9; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.secondary,
button.outline {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}
button.secondary:hover:not(:disabled),
button.outline:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--fg);
  opacity: 1;
}

button.primary { /* explicit — same as default gradient */
  background: linear-gradient(90deg, var(--accent), var(--a2));
  color: #fff;
}

/* Кнопки внутри <label> в фильтрах — не должны растягиваться вверх */
.filters label button { margin-top: 0; }

/* ─── Tables ────────────────────────────────────────────── */
figure {
  margin: 0;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--card);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
thead th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  padding: 0.7rem 0.85rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-top: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.1s;
}
tbody tr:first-child { border-top: none; }
tbody tr:hover { background: rgba(59, 130, 246, 0.06); }
tbody td {
  padding: 0.65rem 0.85rem;
  vertical-align: top;
  color: var(--fg);
}
table button {
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
}

/* ─── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.3;
}
.badge-rating-1, .badge-rating-2 { background: rgba(244, 63, 94, 0.18); color: #fda4af; }
.badge-rating-3 { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.badge-rating-4, .badge-rating-5 { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.badge-priority { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.badge-correction { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; }
.badge-count {
  background: linear-gradient(135deg, var(--accent), var(--a2));
  color: #fff;
  font-family: 'Unbounded', 'Inter', sans-serif;
  font-weight: 700;
  min-width: 1.8rem;
  text-align: center;
  padding: 0.22rem 0.55rem;
}
.badge:not([class*="badge-"]) {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}
.badge-admin {
  background: linear-gradient(135deg, var(--accent), var(--a2));
  color: #fff;
}

/* ─── Distance bars (TestRAG) ───────────────────────────── */
.distance-bar {
  display: inline-block;
  min-width: 56px;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.72rem;
  text-align: center;
  font-weight: 600;
}
.distance-good { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.distance-mid { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.distance-bad { background: rgba(244, 63, 94, 0.18); color: #fda4af; }

/* ─── Pagination ────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.9rem;
}
.pagination span {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
}

/* ─── Dialog / modal ────────────────────────────────────── */
dialog {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  max-width: 760px;
  width: 92vw;
  max-height: 90vh;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
dialog form,
dialog article {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin: 0;
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
dialog header {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
dialog header h2 { font-size: 1rem; margin: 0; }
dialog footer {
  padding: 0.85rem 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  background: var(--card-2);
}
dialog form > label,
dialog #dialog-modal-body,
dialog .dialog-detail {
  padding: 0.6rem 1.1rem;
  display: block;
}
dialog form > label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 500;
}
dialog form > label > small { text-transform: none; letter-spacing: 0; font-weight: 400; }
dialog form > .row {
  padding: 0.4rem 1.1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.7rem;
}
dialog form > label.checkbox {
  padding: 0.75rem 1.1rem;
  flex-direction: row;
  background: var(--card-2);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  margin: 0.5rem 0;
}

/* Body scroll inside modal */
dialog #dialog-modal-body,
dialog form { overflow-y: auto; }
dialog header, dialog footer { flex-shrink: 0; }

dialog button.close {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 1.4rem;
  padding: 0 0.4rem;
  line-height: 1;
  width: auto;
  border-radius: var(--radius-sm);
}
dialog button.close:hover {
  background: var(--bg);
  color: var(--fg);
  opacity: 1;
}

dialog pre {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.78rem;
  line-height: 1.5;
  margin: 0;
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Dialog detail fields */
dialog .field { margin-bottom: 0.75rem; }
dialog .field:last-child { margin-bottom: 0; }
.field-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

/* ─── Chunks list ───────────────────────────────────────── */
.chunks-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.chunk-item {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.5;
}
.chunk-meta {
  color: var(--muted);
  font-size: 0.7rem;
  margin-bottom: 0.25rem;
  font-family: ui-monospace, monospace;
}

/* ─── Cluster cards ─────────────────────────────────────── */
.cluster {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.7rem;
  transition: border-color 0.15s;
}
.cluster:hover { border-color: rgba(59, 130, 246, 0.4); }
.cluster-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.cluster-header h4 {
  margin: 0;
  font-size: 0.95rem;
  flex: 1;
  color: var(--fg);
  font-weight: 600;
  line-height: 1.4;
}
.cluster-questions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.cluster-question {
  font-size: 0.8rem;
  padding: 0.45rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--fg);
  transition: border-color 0.15s;
  line-height: 1.4;
}
.cluster-question:hover { border-color: var(--accent); }
.cluster-question .cq-meta {
  color: var(--muted);
  font-size: 0.7rem;
  margin-left: 0.5rem;
  font-family: ui-monospace, monospace;
}

/* ─── Test RAG ──────────────────────────────────────────── */
.testrag-result {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.2rem;
}
.testrag-block { margin-bottom: 1.1rem; }
.testrag-block:last-child { margin-bottom: 0; }
.testrag-block h3 {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.testrag-block figure,
.testrag-block table { background: var(--card-2); }
.testrag-block pre { max-height: 160px; }

/* ─── Toast notifications ───────────────────────────────── */
#toasts {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 420px;
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 0.85rem;
  color: var(--fg);
  pointer-events: auto;
  animation: toastIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  line-height: 1.4;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast .toast-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  width: auto;
  border-radius: 4px;
}
.toast .toast-close:hover {
  background: var(--bg);
  color: var(--fg);
  opacity: 1;
}
.toast.fade-out { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px); }
}

/* ─── Help icon + popover ───────────────────────────────── */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 5px;
  vertical-align: 1px;
  font-family: inherit;
  line-height: 1;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  text-transform: none;
  letter-spacing: 0;
}
.help-icon:hover { background: var(--accent); color: #fff; }
.help-icon.active { background: var(--accent); color: #fff; transform: scale(1.1); }

.help-popover {
  position: fixed;
  z-index: 10000;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  max-width: 340px;
  min-width: 240px;
  font-size: 0.83rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  animation: popoverIn 0.15s ease;
}
.help-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 14px;
  width: 11px;
  height: 11px;
  background: var(--card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.help-popover.flip-up::before { top: auto; bottom: -6px; transform: rotate(225deg); }
@keyframes popoverIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ─── Tab help (обучающий блок) ─────────────────────────── */
.tab-help {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 1.2rem;
  overflow: hidden;
}
.tab-help > summary {
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  user-select: none;
  transition: background 0.15s;
}
.tab-help > summary:hover { background: var(--card-2); }
.tab-help > summary::-webkit-details-marker,
.tab-help > summary::marker { display: none; content: ''; }
.tab-help > summary::before {
  content: '▸';
  color: var(--accent);
  transition: transform 0.2s;
  display: inline-block;
  font-size: 0.75rem;
}
.tab-help[open] > summary::before { transform: rotate(90deg); }
.tab-help-body {
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 0.9rem;
  color: var(--fg);
  line-height: 1.6;
  font-size: 0.88rem;
}
.tab-help-body ol, .tab-help-body ul { padding-left: 1.4rem; margin: 0.6rem 0; }
.tab-help-body li { margin-bottom: 0.4rem; }
.tab-help-body p { margin: 0.6rem 0; }
.tab-help-body strong { color: var(--fg); font-weight: 600; }
.tab-help-body .intro { color: var(--muted); margin-bottom: 0.8rem; }
.tab-help-body .tip {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--fg);
}
.tab-help-body .tip strong { color: var(--accent); }

/* ─── Dialogs dashboard + star-filter ───────────────────── */
.dialogs-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  color: var(--fg);
  font-family: inherit;
  min-height: 62px;
}
.stat-card.stat-static { cursor: default; }
.stat-card:not(.stat-static):hover {
  border-color: var(--accent);
  background: var(--card-2);
}
.stat-card:not(.stat-static):active { transform: scale(0.99); }
.stat-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
  background: var(--card-2);
}
.stat-card.kind-bad.active { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger) inset; }
.stat-card.kind-mid.active { border-color: var(--warning); box-shadow: 0 0 0 1px var(--warning) inset; }
.stat-card.kind-ok.active  { border-color: var(--success); box-shadow: 0 0 0 1px var(--success) inset; }
.stat-card.kind-muted.active { border-color: var(--muted); box-shadow: 0 0 0 1px var(--muted) inset; }
.stat-card.kind-noinfo.active { border-color: var(--warning); box-shadow: 0 0 0 1px var(--warning) inset; }

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  font-family: 'Unbounded', 'Inter', sans-serif;
  letter-spacing: -0.01em;
}
.stat-card.kind-bad .stat-value { color: var(--danger); }
.stat-card.kind-mid .stat-value { color: var(--warning); }
.stat-card.kind-ok .stat-value  { color: var(--success); }
.stat-card.kind-muted .stat-value { color: var(--muted); }
.stat-card.kind-noinfo .stat-value { color: var(--warning); }
.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* Фильтр в одну строку */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 14px;
}

.star-filter {
  display: inline-flex;
  gap: 4px;
  background: var(--card-2);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 3px;
}
.star-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  font-family: inherit;
  min-width: 44px;
}
.star-btn:hover { color: var(--fg); background: var(--card); }
.star-btn.active { color: var(--fg); border-color: currentColor; }
.star-btn.kind-bad.active { background: rgba(244, 63, 94, 0.2); color: #fda4af; }
.star-btn.kind-mid.active { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.star-btn.kind-ok.active  { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }

.chip-btn {
  background: var(--card-2);
  color: var(--muted);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip-btn:hover { color: var(--fg); background: var(--card); }
.chip-btn.active {
  background: rgba(156, 163, 175, 0.2);
  color: var(--fg);
  border-color: var(--muted);
}
.chip-btn.chip-noinfo.active {
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
  border-color: var(--warning);
}

.dialogs-table tbody tr.no-info { background: rgba(245, 158, 11, 0.08); }
.dialogs-table tbody tr.no-info:hover { background: rgba(245, 158, 11, 0.14); }

.badge-noinfo { background: rgba(245, 158, 11, 0.20); color: #fcd34d; }

.filter-inline-select,
.filter-inline-input {
  background: var(--card-2);
  color: var(--fg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.85rem;
}
.filter-inline-input { min-width: 220px; flex: 1; }
.filter-inline-select:focus,
.filter-inline-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.filter-row .help-icon { margin-left: auto; }

/* ─── Trainer (ИИ-тренер) ───────────────────────────────── */
.trainer-intro {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.trainer-intro-text { flex: 1; }
.trainer-intro-text h3 { margin-bottom: 6px; }
.trainer-intro-text p {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}
.trainer-intro-text code {
  background: var(--card-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82rem;
}
.trainer-intro button { flex-shrink: 0; }

.chat-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 320px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px 18px;
  margin-bottom: 12px;
  position: relative;
}
.chat-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 2rem;
  pointer-events: none;
}
.chat-empty-icon { font-size: 2.2rem; margin-bottom: 8px; opacity: 0.6; }
.chat-empty-title { font-weight: 600; color: var(--fg); margin-bottom: 4px; }
.chat-empty-hint { font-size: 0.82rem; color: var(--muted); }

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 90%;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  animation: fadeInUp 0.2s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.chat-message-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--a2));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-message-user .bubble-label {
  font-size: 0.72rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.chat-message-user pre {
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  border-radius: 6px;
  padding: 6px 8px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.88rem;
}

.chat-message-bot,
.chat-message-trainer,
.chat-message-system,
.chat-message-success,
.chat-message-error {
  align-self: flex-start;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--fg);
  border-bottom-left-radius: 4px;
}
.chat-message-bot { border-left: 3px solid var(--accent); }
.chat-message-trainer { border-left: 3px solid var(--a2); }
.chat-message-success {
  border-left: 3px solid var(--success);
  background: rgba(16, 185, 129, 0.08);
}
.chat-message-error {
  border-left: 3px solid var(--danger);
  background: rgba(239, 68, 68, 0.08);
}
.chat-message-system {
  border-left: 3px solid var(--muted-2);
  font-size: 0.85rem;
  color: var(--muted);
}

.bubble-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.chat-message-bot .bubble-label { color: var(--accent); }
.chat-message-trainer .bubble-label { color: var(--a2); }
.chat-message-success .bubble-label { color: var(--success); }
.chat-message-error .bubble-label { color: var(--danger); }

.bubble-body pre {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--fg);
}
.bubble-body { color: var(--fg); }

.bubble-details {
  margin-top: 8px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border-soft);
}
.bubble-details > summary {
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--muted);
  list-style: none;
}
.bubble-details > summary::-webkit-details-marker { display: none; }
.bubble-details > summary::before { content: '▸ '; color: var(--muted-2); }
.bubble-details[open] > summary::before { content: '▾ '; }
.bubble-details-body {
  padding: 8px 10px;
  border-top: 1px solid var(--border-soft);
}
.bubble-sub-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 4px;
}
.bubble-sub-label:first-child { margin-top: 0; }

.matched-correction {
  background: var(--card);
  border-radius: 6px;
  padding: 8px 10px;
  border-left: 2px solid var(--success);
}
.matched-correction .matched-q { margin: 4px 0; font-size: 0.85rem; }
.matched-correction pre {
  background: var(--bg);
  border-radius: 4px;
  padding: 6px 8px;
  margin: 0;
  font-size: 0.82rem;
}

.chat-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Chat input row ───────────────────────────────────── */
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input-row textarea {
  flex: 1;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
  min-height: 52px;
}
.chat-input-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.chat-input-row button {
  height: 52px;
  padding: 0 18px;
}

/* ─── Proposal card ────────────────────────────────────── */
.proposal-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proposal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.proposal-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--a2));
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
}
.proposal-target {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}
.proposal-field { display: flex; flex-direction: column; gap: 4px; }
.proposal-field-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.proposal-field-body {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.88rem;
}
.proposal-tags { gap: 8px; }
.proposal-tags .tag {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: var(--muted);
}
.proposal-tags .tag strong { color: var(--fg); }

.proposal-details {
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border-soft);
}
.proposal-details > summary {
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  list-style: none;
}
.proposal-details > summary::-webkit-details-marker { display: none; }
.proposal-details > summary::before { content: '▸ '; color: var(--muted-2); }
.proposal-details[open] > summary::before { content: '▾ '; }
.paraphrase-list {
  margin: 0;
  padding: 8px 10px 10px 28px;
  border-top: 1px solid var(--border-soft);
}
.paraphrase-list li { font-size: 0.86rem; margin: 3px 0; }
.proposal-reasoning {
  padding: 8px 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.proposal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.proposal-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proposal-edit-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}
.proposal-edit-form textarea,
.proposal-edit-form input[type="text"],
.proposal-edit-form select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.88rem;
}
.proposal-edit-form .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.proposal-edit-form .checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  font-size: 0.85rem;
}

/* ─── Scrollbar (webkit) ────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #2a3858; }

/* ─── Firefox scrollbar ─────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ─────────────────────────────────────────────────────────
   Responsive (tablet ≤960, mobile ≤640, small ≤420)
   ───────────────────────────────────────────────────────── */

/* Tablet breakpoint: уплотнение перед мобилкой */
@media (max-width: 960px) {
  .container-fluid { padding: 0 16px; }
  .dialogs-dashboard { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .filters .grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* Mobile breakpoint: основная перестройка */
@media (max-width: 640px) {
  /* ─ Layout & container ─ */
  body { line-height: 1.55; }
  .container-fluid { padding: 0 12px; }
  main.container-fluid { padding-top: 14px; padding-bottom: 32px; }

  /* ─ Header: две строки (лого/health сверху, tabs снизу) ─ */
  .app-header {
    height: auto;
    min-height: 56px;
    padding: 8px 0;
  }
  .app-header .container-fluid {
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  .app-header strong {
    font-size: 0.9rem;
    flex: 1 1 auto;
  }
  .app-header .user-chip {
    margin-left: auto;
    flex-shrink: 0;
  }
  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.72rem;
  }
  .user-menu {
    right: 0;
    min-width: 220px;
    max-width: calc(100vw - 24px);
  }

  /* ─ Tabs: горизонтальный скролл вместо wrap ─ */
  .tabs {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    gap: 4px;
    padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab {
    flex: 0 0 auto;
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    white-space: nowrap;
    scroll-snap-align: center;
  }

  /* ─ Dashboard: 2 колонки ─ */
  .dialogs-dashboard {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stat-card { padding: 10px 12px; min-height: 58px; }
  .stat-value { font-size: 1.15rem; }
  .stat-label { font-size: 0.72rem; }

  /* ─ Filter row: поиск сверху на всю ширину, звёзды в ряд ─ */
  .filter-row { padding: 10px; gap: 6px; }
  .filter-inline-input {
    order: -1;
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }
  .star-filter {
    width: 100%;
    justify-content: space-between;
    padding: 2px;
  }
  .star-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 4px;
    font-size: 0.8rem;
  }
  .chip-btn,
  .filter-inline-select {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    font-size: 0.8rem;
  }
  #btn-reset-filters, #btn-reload { flex: 0 0 auto; padding: 6px 12px; }
  .filter-row .help-icon { display: none; }

  /* ─ Tables: компактные paddings + визуальный намёк на скролл ─ */
  thead th { padding: 0.55rem 0.55rem; font-size: 0.66rem; }
  tbody td { padding: 0.5rem 0.55rem; font-size: 0.78rem; }
  table button { padding: 0.25rem 0.55rem; font-size: 0.72rem; }
  figure {
    position: relative;
    background:
      linear-gradient(to right, var(--card) 30%, rgba(17,24,39,0)) left center / 20px 100% no-repeat,
      linear-gradient(to left,  var(--card) 30%, rgba(17,24,39,0)) right center / 20px 100% no-repeat,
      linear-gradient(to right, rgba(0,0,0,0.35), rgba(0,0,0,0)) left center / 10px 100% no-repeat,
      linear-gradient(to left,  rgba(0,0,0,0.35), rgba(0,0,0,0)) right center / 10px 100% no-repeat,
      var(--card);
    background-attachment: local, local, scroll, scroll, scroll;
  }

  /* ─ Modals: почти на весь экран ─ */
  dialog {
    width: 96vw;
    max-height: 94vh;
  }
  dialog form,
  dialog article { max-height: 94vh; }
  dialog header { padding: 0.7rem 0.9rem; }
  dialog header h2 { font-size: 0.95rem; }
  dialog footer {
    padding: 0.7rem 0.9rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  dialog footer button { flex: 1 1 auto; min-width: 0; }
  dialog form > label,
  dialog #dialog-modal-body,
  dialog .dialog-detail { padding: 0.55rem 0.9rem; }
  dialog form > .row {
    grid-template-columns: 1fr;
    padding: 0.35rem 0.9rem;
  }
  dialog pre { max-height: 180px; font-size: 0.76rem; }

  /* ─ Filters (общий блок) ─ */
  .filters { padding: 12px 14px; }
  .filters .grid { grid-template-columns: 1fr; gap: 0.6rem; }

  /* ─ Trainer / chat ─ */
  .trainer-intro {
    flex-direction: column;
    gap: 10px;
    padding: 14px;
  }
  .trainer-intro button { align-self: stretch; }
  .chat-container {
    padding: 12px;
    min-height: 260px;
    max-height: 55vh;
  }
  .chat-message {
    max-width: 95%;
    font-size: 0.88rem;
    padding: 9px 12px;
  }
  .chat-message pre,
  .bubble-body pre {
    font-size: 0.8rem;
    padding: 6px 8px;
    overflow-x: auto;
  }
  .chat-input-row { gap: 6px; }
  .chat-input-row textarea { font-size: 0.9rem; padding: 9px 10px; min-height: 46px; }
  .chat-input-row button { height: 46px; padding: 0 14px; font-size: 0.85rem; }

  /* ─ Clusters ─ */
  .cluster { padding: 0.75rem 0.9rem; }
  .cluster-header { gap: 0.5rem; margin-bottom: 0.5rem; }
  .cluster-header h4 { font-size: 0.88rem; flex: 1 1 100%; }
  .cluster-question { font-size: 0.78rem; padding: 0.4rem 0.55rem; }
  .cluster-question .cq-meta {
    display: block;
    margin-left: 0;
    margin-top: 3px;
  }

  /* ─ Test RAG ─ */
  .testrag-result { padding: 0.85rem 0.95rem; }

  /* ─ Help popover: прилип к низу экрана ─ */
  .help-popover {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    top: auto !important;
    bottom: 16px !important;
    max-width: none;
    min-width: 0;
    width: auto;
  }
  .help-popover::before { display: none; }

  /* ─ Toasts ─ */
  #toasts {
    top: auto;
    bottom: 16px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
  .toast { font-size: 0.82rem; padding: 10px 12px; }

  /* ─ Pagination / misc ─ */
  .pagination { flex-wrap: wrap; gap: 0.4rem; }
  .pagination button { flex: 1 1 auto; padding: 0.45rem 0.8rem; font-size: 0.8rem; }
  .pagination span { flex: 1 1 100%; text-align: center; }

  /* ─ Tab-help (обучающие блоки) ─ */
  .tab-help > summary { padding: 0.75rem 0.9rem; font-size: 0.85rem; }
  .tab-help-body { padding: 0 0.9rem 0.9rem; padding-top: 0.75rem; font-size: 0.85rem; }

  /* ─ Proposal card (ИИ-тренер) ─ */
  .proposal-edit-form .row { grid-template-columns: 1fr; }
  .proposal-actions button { flex: 1 1 auto; }
}

/* Small phones: ещё компактнее */
@media (max-width: 420px) {
  .container-fluid { padding: 0 10px; }
  .app-header strong { font-size: 0.85rem; }
  .stat-value { font-size: 1.05rem; }
  .stat-label { font-size: 0.68rem; }
  .stat-card { padding: 9px 10px; min-height: 52px; }
  .star-btn { padding: 6px 2px; font-size: 0.78rem; }
  .chip-btn, .filter-inline-select { font-size: 0.78rem; padding: 5px 10px; }
  thead th { padding: 0.5rem 0.45rem; font-size: 0.62rem; }
  tbody td { padding: 0.45rem 0.45rem; font-size: 0.75rem; }
  .chat-input-row {
    flex-direction: column;
    align-items: stretch;
  }
  .chat-input-row button { width: 100%; height: 42px; }
  dialog { width: 98vw; max-height: 96vh; }
  dialog footer button { font-size: 0.8rem; padding: 0.5rem 0.7rem; }
}

.audit-table td { vertical-align: top; font-size: 0.9rem; }
.audit-table td:nth-child(1) { white-space: nowrap; color: var(--pico-muted-color); }
.audit-table td:nth-child(5) { word-break: break-word; }
.audit-table td:nth-child(5) > div { margin-bottom: 0.15rem; }

/* ─── Chat2Desk ─────────────────────────────────────── */
.c2d-row { cursor: pointer; }
.c2d-row:hover td { background: rgba(255, 255, 255, 0.03); }

.c2d-lang-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--pico-muted-color);
  text-transform: uppercase;
}

.c2d-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}
.c2d-status-new               { background: rgba(56, 139, 253, 0.15); color: #58a6ff; }
.c2d-status-in_review         { background: rgba(219, 189, 25, 0.15); color: #e3b341; }
.c2d-status-correction_created{ background: rgba(46, 160, 67, 0.18); color: #3fb950; }
.c2d-status-rejected          { background: rgba(248, 81, 73, 0.15); color: #f85149; }
.c2d-status-archived          { background: rgba(255, 255, 255, 0.06); color: var(--pico-muted-color); }
.c2d-status-review_pii        { background: rgba(255, 123, 114, 0.18); color: #ff9f8a; }

/* Модалка транскрипта */
#c2d-dialog-modal { max-width: 760px; width: 92vw; }
.c2d-meta {
  padding: 6px 2px 2px;
  margin-top: 6px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--pico-muted-color);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.c2d-meta > div { display: inline; }
.c2d-meta > div + div::before { content: ' · '; opacity: 0.5; }
.c2d-meta strong { color: var(--pico-muted-color); font-weight: 600; opacity: 0.85; }

.c2d-transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px 4px;
}

.c2d-msg {
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 85%;
  font-size: 0.88rem;
  line-height: 1.5;
}
.c2d-msg-client {
  align-self: flex-start;
  background: rgba(56, 139, 253, 0.12);
  border: 1px solid rgba(56, 139, 253, 0.25);
}
.c2d-msg-operator {
  align-self: flex-end;
  background: rgba(46, 160, 67, 0.12);
  border: 1px solid rgba(46, 160, 67, 0.25);
}
.c2d-msg-system {
  align-self: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  color: var(--pico-muted-color);
  font-style: italic;
  font-size: 0.82rem;
}

.c2d-msg-head {
  font-size: 0.72rem;
  color: var(--pico-muted-color);
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.c2d-msg-ts { margin-left: auto; font-variant-numeric: tabular-nums; }
.c2d-msg-body { white-space: pre-wrap; word-break: break-word; }
.c2d-msg-attach {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--pico-muted-color);
}
.c2d-msg-attach a { color: #58a6ff; }

/* Шапка над textarea: название поля слева + вспомогательная кнопка справа */
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 4px;
}
.ai-generate-btn {
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ai-generate-btn:disabled { opacity: 0.6; cursor: wait; }

/* Кнопки выбора роли сообщения (В/О) */
.c2d-role-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-right: 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: var(--pico-muted-color);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.c2d-role-btn:hover { background: rgba(255, 255, 255, 0.1); }
.c2d-role-btn.c2d-role-q[aria-pressed="true"] {
  background: #58a6ff;
  border-color: #58a6ff;
  color: #0b1220;
}
.c2d-role-btn.c2d-role-a[aria-pressed="true"] {
  background: #3fb950;
  border-color: #3fb950;
  color: #0b1220;
}

.c2d-msg--selected-q { border-left: 3px solid #58a6ff; }
.c2d-msg--selected-a { border-left: 3px solid #3fb950; }

.c2d-msg-head > span:first-of-type { flex: 0 0 auto; }

/* Компактный блок под кнопками: подсказка и preview выбранных текстов */
.c2d-selection {
  padding: 4px 2px 0;
  margin-top: 2px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--pico-muted-color);
}
.c2d-selection-hint {
  font-size: 0.7rem;
  opacity: 0.75;
}
.c2d-role-hint {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  font-weight: 700;
  text-align: center;
  line-height: 14px;
  font-size: 0.62rem;
  vertical-align: middle;
}
.c2d-role-hint-q { background: #58a6ff; color: #0b1220; }
.c2d-role-hint-a { background: #3fb950; color: #0b1220; }

.c2d-selection-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 1px 0;
}
.c2d-selection-row strong { color: var(--pico-muted-color); font-weight: 600; }
.c2d-selection-text {
  flex: 1;
  color: var(--pico-color);
  overflow-wrap: anywhere;
  opacity: 0.85;
}
.c2d-selection-count {
  color: var(--pico-muted-color);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .c2d-msg { max-width: 95%; }
  #c2d-dialog-modal { width: 98vw; }
}
