:root {
  --bg: #f5f6f8;
  --fg: #1f2329;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e3e6ea;
  --accent: #2f6feb;
  --warn: #c2410c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px 0;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 { font-size: 20px; margin: 0; }

.chat-picker select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  max-width: 60vw;
}

nav { display: flex; gap: 4px; margin-top: 12px; }

nav a {
  padding: 8px 14px;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-size: 14px;
}
nav a:hover { color: var(--fg); }
nav a.logout { margin-left: auto; color: var(--accent); }

/* --- Страница входа --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 320px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; text-align: center; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
.login-card input {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}
.login-error {
  background: #fdecea;
  color: #b3261e;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0;
  font-size: 14px;
}

/* --- Иконки Lucide --- */
.lucide { vertical-align: -0.18em; flex: none; }
header h1 { display: inline-flex; align-items: center; gap: 8px; }
.login-card h1 { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
nav a { display: inline-flex; align-items: center; gap: 6px; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
td .lucide { margin-right: 2px; }
.card-ic { color: var(--muted); margin-bottom: 2px; }
.card.warn .card-ic { color: var(--warn); }
td.status-cell.unanswered_long { color: var(--warn); }
td.status-cell.unanswered_recent { color: #b45309; }
td.status-cell.answered { color: #15803d; }
.conflict .badge { display: inline-flex; align-items: center; gap: 6px; }
.badge.sev-high { color: #dc2626; }
.badge.sev-medium { color: #ea580c; }
.badge.sev-low { color: #b45309; }

/* --- Индикатор анализа --- */
.banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  margin: 6px 0;
  font-size: 14px;
}
.banner.running { background: #eef4ff; color: #1d4ed8; }
.banner.error { background: #fdecea; color: #b3261e; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.9s linear infinite; transform-origin: center; }

main { max-width: 980px; margin: 0 auto; padding: 24px; }

h2 { margin-top: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.cards { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 24px;
  min-width: 140px;
  display: flex;
  flex-direction: column;
}
.card b { font-size: 28px; }
.card span { color: var(--muted); font-size: 14px; }
.card.warn b { color: var(--warn); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 14px;
}
th { background: #fafbfc; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.nowrap { white-space: nowrap; }

tr.unanswered_long td { background: #fff5f0; }
tr.unanswered_recent td { background: #fffdf2; }

.reply { color: var(--accent); }

.profile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 14px;
}
.profile h3 { margin: 0 0 6px; font-size: 16px; }
.profile p { margin: 6px 0; }

.empty { text-align: center; padding: 48px 12px; color: var(--muted); }
.empty h2 { color: var(--fg); }

/* --- Диаграммы активности --- */
.vchart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 150px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 12px 4px;
  margin-bottom: 26px;
}
.vbar {
  flex: 1 1 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}
.vbar-fill {
  width: 100%;
  max-width: 22px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 0;
}
.vbar-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
}

.cols { display: flex; gap: 20px; flex-wrap: wrap; }
.col { flex: 1 1 320px; min-width: 0; }

.hbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}
.hbar-name {
  flex: 0 0 130px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbar {
  flex: 1 1 auto;
  height: 14px;
  background: #eef0f3;
  border-radius: 7px;
  overflow: hidden;
}
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 7px; }
.hbar-fill.green { background: #2e9e5b; }
.hbar-val { flex: 0 0 auto; font-size: 13px; color: var(--muted); min-width: 28px; text-align: right; }

/* --- Конфликты --- */
.conflict {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
.conflict.high { border-left-color: #dc2626; }
.conflict.medium { border-left-color: #ea580c; }
.conflict.low { border-left-color: #d4a72c; }
.conflict-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.conflict .badge { font-size: 13px; font-weight: 600; }
.conflict blockquote {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: #fafbfc;
  border-radius: 8px;
  font-size: 13px;
  color: var(--fg);
}
