/* app.css — minimal operator stylesheet for the Klerk moderation queue.
   No framework. Primary action (open on Klerk) is the unmistakable focal point. */

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

:root {
  --bg:           #f4f5f7;
  --surface:      #ffffff;
  --border:       #dfe1e5;
  --text:         #172b4d;
  --text-muted:   #5e6c84;
  --primary:      #0052cc;
  --primary-h:    #0747a6;
  --good:         #006644;
  --good-bg:      #e3fcef;
  --bad:          #bf2600;
  --bad-bg:       #ffebe6;
  --badge-high:   #de350b;
  --badge-low:    #ff8b00;
  --radius:       6px;
  --shadow:       0 1px 3px rgba(9,30,66,.13);
}

/* ── Base ──────────────────────────────────────────────────────────────────── */

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow);
}

.app-brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.2px;
  color: var(--text);
}

.app-nav a {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 20px;
  font-size: 14px;
  transition: color .15s;
}

.app-nav a:hover {
  color: var(--primary);
}

/* ── Main container ─────────────────────────────────────────────────────────── */

.app-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}

/* ── Flash messages ─────────────────────────────────────────────────────────── */

.flash-messages {
  margin-bottom: 20px;
}

.flash {
  background: #fffae6;
  border: 1px solid #ffc400;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  color: #172b4d;
}

.flash-error {
  background: var(--bad-bg);
  border-color: #ffbdad;
  color: var(--bad);
}

/* ── Queue header ───────────────────────────────────────────────────────────── */

.queue-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.queue-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.queue-count {
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Empty state ────────────────────────────────────────────────────────────── */

.empty-queue {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
  font-size: 16px;
}

/* ── Comment list ───────────────────────────────────────────────────────────── */

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Comment card ───────────────────────────────────────────────────────────── */

.comment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  transition: box-shadow .15s;
}

.comment-card:hover {
  box-shadow: 0 2px 8px rgba(9,30,66,.18);
}

/* ── Card meta row ──────────────────────────────────────────────────────────── */

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.bucket-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: #fff;
}

.badge-review_high { background: var(--badge-high); }
.badge-review_low  { background: var(--badge-low); }

.score {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.created-at {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Comment text ───────────────────────────────────────────────────────────── */

.card-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
  margin-bottom: 10px;
}

/* ── Reason ─────────────────────────────────────────────────────────────────── */

.card-reason {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── LLM verdict ────────────────────────────────────────────────────────────── */

.llm-verdict {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.llm-spam  { background: var(--bad-bg);  color: var(--bad); }
.llm-clean { background: var(--good-bg); color: var(--good); }

/* ── Signals collapsible ────────────────────────────────────────────────────── */

.signals-details {
  margin-bottom: 14px;
  font-size: 13px;
}

.signals-details summary {
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.signals-details summary::before {
  content: "▶";
  font-size: 10px;
  transition: transform .15s;
}

.signals-details[open] summary::before {
  transform: rotate(90deg);
}

.signals-list {
  list-style: none;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.signal-item {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
}

.signal-meta {
  color: var(--text-muted);
  margin-left: 6px;
  font-family: monospace;
  font-size: 11px;
}

/* ── Card actions ───────────────────────────────────────────────────────────── */

.card-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ── PRIMARY ACTION: open on Klerk ─────────────────────────────────────────── */
/*   This is the unmistakable main control — larger, filled, stands out.        */

.btn-open-klerk {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .1px;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 2px 4px rgba(0,82,204,.3);
}

.btn-open-klerk:hover {
  background: var(--primary-h);
  box-shadow: 0 3px 8px rgba(0,82,204,.35);
  color: #fff;
}

/* ── Label buttons ──────────────────────────────────────────────────────────── */

.label-buttons {
  display: flex;
  gap: 8px;
}

.inline-form {
  display: inline;
}

.btn-good,
.btn-bad {
  padding: 8px 18px;
  border: 2px solid;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  transition: background .15s, color .15s;
  font-family: inherit;
}

.btn-good {
  border-color: var(--good);
  color: var(--good);
}

.btn-good:hover {
  background: var(--good);
  color: #fff;
}

.btn-bad {
  border-color: var(--bad);
  color: var(--bad);
}

.btn-bad:hover {
  background: var(--bad);
  color: #fff;
}

/* ── Secondary button (run) ─────────────────────────────────────────────────── */

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, color .15s;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.run-form {
  display: inline;
}

/* ── Login page ─────────────────────────────────────────────────────────────── */

.login-container {
  max-width: 380px;
  margin: 72px auto;
}

.login-container h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--text);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: -8px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  padding: 9px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  color: var(--text);
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,82,204,.12);
}

.login-form .btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-top: 4px;
  transition: background .15s;
}

.login-form .btn-primary:hover {
  background: var(--primary-h);
}

/* ── Auth-locked notice ─────────────────────────────────────────────────────── */

.auth-locked {
  background: var(--bad-bg);
  border: 1px solid #ffbdad;
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 14px;
  color: #6b2727;
  line-height: 1.6;
}

.auth-locked code {
  font-family: monospace;
  font-size: 13px;
  background: rgba(0,0,0,.06);
  padding: 1px 5px;
  border-radius: 3px;
}

/* --- Очередь: фильтры + пагинация --- */
.queue-filters {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
}
.filter-chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
  text-decoration: none;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 24px 0 8px;
}
.pager-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}
.pager-btn:hover { border-color: var(--primary); }
.pager-btn.disabled {
  color: var(--text-muted);
  opacity: .5;
  pointer-events: none;
}
.pager-info { color: var(--text-muted); font-size: 14px; }

/* --- Аналитика --- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.metric-value { font-size: 28px; font-weight: 700; color: var(--text); }
.metric-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.analytics-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.stat-list { list-style: none; padding: 0; margin: 0; }
.stat-list li { padding: 4px 0; color: var(--text); font-size: 14px; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot-good { background: var(--good); }
.dot-bad { background: var(--bad); }
.hint { font-size: 13px; color: var(--text-muted); margin: 10px 0 0; }

.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-date { width: 48px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bar-track { flex: 1; background: var(--bg); border-radius: 3px; height: 16px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 3px; min-width: 2px; }
.bar-count { width: 32px; text-align: right; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --- Настройки --- */
.settings-form .panel { max-width: 560px; }
.advanced-settings summary {
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.advanced-settings[open] summary { margin-bottom: 12px; }
.advanced-warning {
  color: var(--bad);
  background: var(--bad-bg);
  padding: 8px 10px;
  border-radius: var(--radius);
  margin: 8px 0 12px;
}
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  font-size: 14px;
}
.field span { color: var(--text); }
.field input {
  width: 120px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  text-align: right;
}
.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 14px;
  cursor: pointer;
}
.switch-row input { width: 16px; height: 16px; }
.settings-form > .btn-primary { margin-top: 4px; }
.textarea-full {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}

/* --- Проверка (lookup) --- */
.lookup-form { display: flex; gap: 8px; margin: 12px 0 20px; }
.lookup-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.badge-pass { background: var(--good); }
.flash-error { background: var(--bad-bg); color: var(--bad); }

.export-links { display: flex; gap: 10px; flex-wrap: wrap; }
.export-links .btn-secondary { text-decoration: none; }

.author { color: var(--text-muted); font-size: 13px; }
.author code {
  font-family: monospace;
  font-size: 12px;
  background: rgba(0,0,0,.06);
  padding: 1px 5px;
  border-radius: 3px;
}

/* --- Keyboard hint --- */
.kbd-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -8px 0 16px;
}
.kbd-hint kbd {
  font-family: monospace;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
}

/* --- Focused card (keyboard nav) --- */
.comment-card.card-focused {
  box-shadow: 0 0 0 2px var(--primary), var(--shadow);
}

/* --- Article link --- */
.article-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}
.article-link:hover { color: var(--primary); }

/* --- Full-text expand --- */
.text-expand { margin-top: 4px; font-size: 13px; }
.text-expand summary {
  cursor: pointer;
  color: var(--primary);
  list-style: none;
}
.text-full { margin-top: 6px; white-space: pre-wrap; }

/* --- Quick trusted-author button --- */
.btn-tiny {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.btn-tiny:hover { border-color: var(--primary); color: var(--primary); }
.btn-tiny-done {
  color: var(--good);
  border-color: var(--good);
  cursor: default;
}

/* --- Resolved strip (undo) --- */
.resolved-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.btn-undo {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  text-decoration: underline;
}

/* --- Forward-to-Boris --- */
.boris-form { margin-left: auto; }
.boris-form summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.boris-form summary:hover { border-color: var(--primary); color: var(--primary); }
.boris-form[open] summary { margin-bottom: 8px; }
.boris-note-form { display: flex; gap: 8px; }
.boris-note-input {
  flex: 1;
  min-width: 220px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}
.btn-boris {
  padding: 7px 14px;
  border: 1px solid var(--badge-low);
  border-radius: var(--radius);
  background: transparent;
  color: var(--badge-low);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-boris:hover { background: var(--badge-low); color: #fff; }

/* --- История решений --- */
.history-search-form {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
}
.history-search-form .lookup-input { flex: 1; max-width: 360px; }

.history-list { gap: 10px; }
.history-row { padding: 14px 20px; }

.decision-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.decision-good { background: var(--good); }
.decision-bad  { background: var(--bad); }
.decision-boris { background: var(--badge-low); }

.mismatch-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #7a4a00;
  background: #fff0b3;
  border: 1px solid #ffab00;
}

.boris-closed-tag {
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.history-text-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-actions .btn-tiny[disabled] {
  opacity: .5;
  cursor: default;
}
