/* app.css — hh-pilot panel styles (no external CDN, mobile-first) */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Design tokens (SPEC §4) */
  --bg:        #0f1115;
  --surface:   #16181d;
  --surface2:  #1e2128;
  --border:    #26292f;
  --text:      #e6e8ec;
  --muted:     #8b93a1;
  --green:     #2ea043;
  --red:       #f0483e;
  --yellow:    #d29922;
  --blue:      #2f6feb;
  --radius-sm: 8px;
  --radius:    12px;
  --header-h:  52px;
  --nav-h:     48px;
}

html { overflow-x: hidden; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ─── Error / Toast ─── */
#error-banner {
  background: var(--red);
  color: #fff;
  padding: 10px 16px;
  text-align: center;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  font-size: 14px;
}

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.stop-indicator {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  animation: pulse 1.5s infinite;
  white-space: nowrap;
  flex-shrink: 0;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.55} }

/* ─── Nav chips ─── */
.nav-wrap {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 99;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-wrap::-webkit-scrollbar { display: none; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  padding-left: calc(12px + env(safe-area-inset-left));
  width: max-content;
  min-width: 100%;
}

.tab-btn {
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.tab-btn:hover  { color: var(--text); border-color: var(--blue); }
.tab-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

/* ─── Main content ─── */
main {
  padding: 16px;
  padding-left:  calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 1400px;
  margin: 0 auto;
}

.tab-section { display: none; }
.tab-section.active { display: block; }

/* ─── Section heading ─── */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* ─── Cards / surfaces ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-green  { border-color: var(--green); color: var(--green); }
.btn-green:hover:not(:disabled)  { background: var(--green); color: #fff; }
.btn-red    { border-color: var(--red); color: var(--red); }
.btn-red:hover:not(:disabled)    { background: var(--red);   color: #fff; }
.btn-blue   { border-color: var(--blue); color: var(--blue); }
.btn-blue:hover:not(:disabled)   { background: var(--blue);  color: #fff; }
.btn-stop {
  border-color: var(--red);
  color: var(--red);
  font-weight: 700;
}
.btn-stop:hover:not(:disabled) { background: var(--red); color: #fff; }
.btn-stop.active { background: var(--red); color: #fff; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ─── Status / Overview ─── */
.counts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 600px) {
  .counts-grid { grid-template-columns: repeat(6, 1fr); }
}
.count-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.count-card.c-green  { border-color: var(--green); }
.count-card.c-red    { border-color: var(--red); }
.count-card.c-blue   { border-color: var(--blue); }
.count-card.c-yellow { border-color: var(--yellow); }
.cnt-num   { display: block; font-size: 26px; font-weight: 700; }
.cnt-label { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

.status-section { margin-bottom: 20px; }
.status-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.limit-block { flex: 1; min-width: 180px; }
.limit-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress-bar  { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 4px; transition: width .3s; }
.token-block { font-size: 13px; color: var(--muted); }
.token-block b { color: var(--text); }

/* Attention block */
.attention-block {
  background: var(--surface);
  border: 1px solid var(--yellow);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.attention-title { font-weight: 600; font-size: 14px; color: var(--yellow); margin-bottom: 10px; }
.attention-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.attention-list li { font-size: 13px; }
.attention-list a { color: var(--blue); text-decoration: none; }
.attention-list a:hover { text-decoration: underline; }

/* Actions block */
.actions-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 600px) {
  .actions-block { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .actions-block { grid-template-columns: repeat(4, 1fr); }
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: border-color .15s;
}
.action-card:hover:not(.disabled) { border-color: var(--blue); }
.action-card.disabled { opacity: .5; cursor: not-allowed; }
.action-card-title { font-weight: 600; font-size: 14px; }
.action-card-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.action-card-btn { margin-top: 8px; }

.stop-block { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stop-hint { font-size: 13px; color: var(--muted); }

/* Recent events */
.events-block { margin-top: 4px; }
.events-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--muted); }
.event-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.event-row:last-child { border-bottom: none; }
.event-time { color: var(--muted); white-space: nowrap; flex-shrink: 0; font-size: 12px; margin-top: 1px; }
.event-lvl  { font-weight: 600; flex-shrink: 0; font-size: 12px; }
.event-msg  { overflow-wrap: break-word; min-width: 0; }
.lvl-info  { color: var(--muted); }
.lvl-warn  { color: var(--yellow); }
.lvl-error { color: var(--red); }
.lvl-alert { color: var(--red); font-weight: 700; }

/* Runs list */
.runs-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.run-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
  font-size: 13px;
}
.run-kind  { font-weight: 600; }
.run-time  { color: var(--muted); font-size: 12px; }
.run-note  { color: var(--muted); font-size: 12px; flex: 1; min-width: 0; overflow-wrap: break-word; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-queued   { background: rgba(210,153,34,.15);  color: var(--yellow); }
.badge-running  { background: rgba(47,111,235,.15);  color: var(--blue); }
.badge-done     { background: rgba(46,160,67,.15);   color: var(--green); }
.badge-error    { background: rgba(240,72,62,.15);   color: var(--red); }
.badge-cancelled{ background: rgba(139,147,161,.15); color: var(--muted); }

/* Verdict/state */
.badge-keep     { background: rgba(46,160,67,.15);   color: var(--green); }
.badge-drop     { background: rgba(240,72,62,.15);   color: var(--red); }
.badge-pending  { background: rgba(210,153,34,.15);  color: var(--yellow); }
.badge-new      { background: rgba(210,153,34,.12);  color: var(--yellow); }
.badge-approved { background: rgba(46,160,67,.12);   color: var(--green); }
.badge-skipped  { background: rgba(139,147,161,.12); color: var(--muted); }
.badge-applied  { background: rgba(47,111,235,.12);  color: var(--blue); }
.badge-failed   { background: rgba(240,72,62,.12);   color: var(--red); }

/* ─── Vacancies (was Queue) ─── */
.vac-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}
.vac-filters select,
.vac-filters input[type="text"] {
  min-height: 44px;
  padding: 0 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  flex: 1;
  min-width: 120px;
}
.vac-filters select:focus,
.vac-filters input:focus { outline: none; border-color: var(--blue); }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
}

.vacancy-list { display: flex; flex-direction: column; gap: 12px; }

.vacancy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.vacancy-card.v-keep    { border-left: 3px solid var(--green); }
.vacancy-card.v-drop    { border-left: 3px solid var(--red); }
.vacancy-card.v-pending { border-left: 3px solid var(--yellow); }

.vacancy-head {
  padding: 12px 14px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.vacancy-check {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--blue);
}
.vacancy-info { flex: 1 1 200px; min-width: 0; }
.vacancy-title {
  font-weight: 600;
  font-size: 15px;
  overflow-wrap: break-word;
  /* Название — не больше двух строк, иначе карточка распухает */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vacancy-title a { color: var(--blue); text-decoration: none; }
.vacancy-title a:hover { text-decoration: underline; }
.vacancy-meta { font-size: 13px; color: var(--muted); margin-top: 3px; overflow-wrap: break-word; }
.vacancy-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: flex-start;
  flex: 0 1 auto;
}

/* На узком экране бейджи уезжают на свою строку, а не сжимают название */
@media (max-width: 520px) {
  .vacancy-badges {
    flex-basis: 100%;
    margin-left: 30px;
  }
}

.reason-box {
  margin: 10px 14px;
  background: var(--surface2);
  border-left: 3px solid var(--yellow);
  border-radius: 0 4px 4px 0;
  padding: 8px 12px;
  font-size: 13px;
  overflow-wrap: break-word;
}
.reason-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; text-transform: uppercase; }

/* Collapsible description */
.vac-desc-toggle {
  font-size: 12px;
  color: var(--blue);
  cursor: pointer;
  padding: 4px 14px;
  background: none;
  border: none;
  text-align: left;
}
.vac-desc-body {
  padding: 0 14px 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  display: none;
}
.vac-desc-body.open { display: block; }

.letter-area {
  display: block;
  width: 100%;
  min-height: 72px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  margin: 0 0 8px;
}
.letter-area:focus { outline: none; border-color: var(--blue); }

/* Сопроводительное письмо: свёрнуто в 3 строки, раскрывается по кнопке */
.letter-box { padding: 0 14px 10px; }
.letter-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.letter-text {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}
.letter-text.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 5.1em;
}
.letter-text.clamped.open {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  max-height: none;
}
.letter-toggle { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.btn.linkish {
  background: none;
  border: 0;
  color: var(--blue);
  padding: 0;
  min-height: 44px;
  font-size: 14px;
}
.btn.linkish:hover { text-decoration: underline; }
.letter-edit { margin-top: 8px; }

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 14px 14px;
}

.pagination { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; justify-content: center; }

/* ─── Chats ─── */
.chats-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: auto;
}
@media (min-width: 768px) {
  .chats-layout {
    flex-direction: row;
    height: 75vh;
  }
}

.chat-list {
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 300px;
}
@media (min-width: 768px) {
  .chat-list { width: 280px; flex-shrink: 0; max-height: none; }
}

.chat-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.chat-item:last-child { border-bottom: none; }
.chat-item:hover { background: var(--surface2); }
.chat-item.selected { background: var(--surface2); border-left: 3px solid var(--blue); }
.chat-item.needs-reply { border-left: 3px solid var(--yellow); }
.chat-employer { font-weight: 600; font-size: 14px; overflow-wrap: break-word; }
.chat-needs-badge { font-size: 11px; font-weight: 700; color: var(--yellow); margin-left: 6px; }
.chat-vacancy { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: break-word; }
.chat-last { font-size: 12px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 400px;
}
@media (min-width: 768px) { .chat-detail { min-height: 0; } }

.chat-detail-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  font-size: 14px;
  overflow-wrap: break-word;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: break-word;
}
.msg-in  { background: var(--surface2); border: 1px solid var(--border); align-self: flex-start; }
.msg-out { background: rgba(47,111,235,.15); border: 1px solid var(--blue); align-self: flex-end; }
.msg-time { font-size: 11px; color: var(--muted); margin-top: 4px; }

.chat-draft-area {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}
.draft-textarea {
  width: 100%;
  min-height: 72px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 8px;
}
.draft-textarea:focus { outline: none; border-color: var(--blue); }
.send-warning {
  font-size: 12px;
  color: var(--yellow);
  margin-bottom: 8px;
}

.placeholder { color: var(--muted); padding: 40px; text-align: center; }

/* ─── Legend ─── */
.legend-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 900px) {
  .legend-layout { flex-direction: row; }
}
.legend-editor { flex: 1; }
.legend-editor textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px;
  font-family: monospace;
  font-size: 16px;
  resize: vertical;
  min-height: 220px;
}
.legend-editor textarea:focus { outline: none; border-color: var(--blue); }
.legend-info {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
}
.legend-preview {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.legend-preview pre {
  white-space: pre-wrap;
  font-size: 13px;
  font-family: monospace;
  color: var(--text);
  overflow-wrap: break-word;
}

/* ─── Settings ─── */
.settings-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.settings-group-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 600px) {
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
}
.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.field-label.full { grid-column: 1 / -1; }
.field-name { color: var(--text); font-weight: 500; font-size: 14px; }
.field-hint { font-size: 12px; color: var(--muted); }
.field-label input,
.field-label textarea,
.field-label select {
  margin-top: 2px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  width: 100%;
}
.field-label input:focus,
.field-label textarea:focus,
.field-label select:focus { outline: none; border-color: var(--blue); }
.field-label textarea { min-height: 72px; resize: vertical; }
.toggle-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.toggle-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 0;
  cursor: pointer;
  accent-color: var(--blue);
  flex-shrink: 0;
}
.toggle-info { display: flex; flex-direction: column; }
.toggle-name { color: var(--text); font-weight: 500; font-size: 14px; }
.toggle-hint { font-size: 12px; color: var(--muted); }

/* ─── LLM ─── */
.llm-form {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.llm-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.llm-form label span { color: var(--text); font-weight: 500; font-size: 14px; }
.llm-form input {
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  width: 100%;
}
.llm-form input:focus { outline: none; border-color: var(--blue); }
.test-result {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 4px;
  overflow-wrap: break-word;
}
.test-result.ok   { background: rgba(46,160,67,.15);  border: 1px solid var(--green); color: var(--green); }
.test-result.fail { background: rgba(240,72,62,.15);  border: 1px solid var(--red);   color: var(--red); }

/* ─── Log ─── */
.log-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: flex-end;
}
.log-filters select {
  min-height: 44px;
  padding: 0 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
}

/* Log card list (replaces table) */
.log-list { display: flex; flex-direction: column; gap: 6px; }
.log-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 13px;
}
.log-item.log-warn  { border-left: 3px solid var(--yellow); }
.log-item.log-error { border-left: 3px solid var(--red); }
.log-item.log-alert { border-left: 3px solid var(--red); background: rgba(240,72,62,.06); }
.log-meta { color: var(--muted); white-space: nowrap; font-size: 12px; }
.log-msg  { overflow-wrap: break-word; grid-column: 2; }

/* ─── Utils ─── */
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
code { background: var(--surface2); padding: 1px 5px; border-radius: 3px; font-size: 13px; }

.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-yellow{ color: var(--yellow); }
.text-blue  { color: var(--blue); }

/* ─── Фильтры: правила отбора и профили поиска ─── */
.filters-h3 { margin-top: 24px; }
.filter-block { margin-bottom: 12px; }
.filter-block-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.filter-note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 12px;
  overflow-wrap: break-word;
}
.filter-block .settings-grid { gap: 12px; }
.filter-block .filter-note:last-child { margin-bottom: 0; }

/* Чекбоксы-чипы: крупная тач-цель, перенос по строкам, без переполнения */
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
  cursor: pointer;
  flex: 1 1 150px;
  min-width: 0;
  max-width: 100%;
}
.chip-check:hover { border-color: var(--blue); }
.chip-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 0;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--blue);
}
.chip-check span { min-width: 0; overflow-wrap: break-word; }
.field-sub { width: 100%; }

/* Профили поиска */
.profile-card { margin-bottom: 12px; }
.profile-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.profile-name { font-size: 15px; font-weight: 700; color: var(--text); overflow-wrap: break-word; }
.profile-toggle { margin-left: auto; min-height: 44px; }

/* Результат проверки на очереди */
.dry-run-result {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.dry-run-line { font-weight: 600; color: var(--text); margin-bottom: 8px; }
.dry-run-item { padding: 8px 0; border-top: 1px solid var(--border); }
.dry-run-item:first-child { border-top: 0; padding-top: 0; }
.dr-name { color: var(--text); font-size: 13px; font-weight: 500; overflow-wrap: break-word; }
.dr-meta { color: var(--muted); font-size: 12px; overflow-wrap: break-word; }

@media (min-width: 600px) {
  .chip-check { flex: 0 1 auto; min-width: 150px; }
}

/* Сетка полей настроек: на телефоне одна колонка, на широком экране — несколько.
   Без этого на 1440px каждое поле занимало целую строку и вкладка выглядела растянутой. */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 18px;
  align-items: end;
}
.filter-grid .field-label { margin: 0; }
@media (max-width: 520px) {
  .filter-grid { grid-template-columns: 1fr; }
}
