/* TG Poster — светлая тема в логике Telegram:
   список чатов слева, карточки-сообщения, синий акцент, круглые аватары. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --surface-3: #e9ebee;
  --border: #e6e8eb;
  --text: #0f0f10;
  --muted: #707579;
  --muted-2: #98a0a6;
  --accent: #3390ec;
  --accent-hover: #2b82d9;
  --accent-soft: #e8f3fd;
  --ok: #2f9e44;
  --ok-soft: #e7f6ea;
  --warn: #d9930d;
  --warn-soft: #fdf3e0;
  --bad: #e0483f;
  --bad-soft: #fdeceb;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-2: 0 2px 8px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-3: 0 8px 28px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .05);
  --ring: 0 0 0 3px rgba(51, 144, 236, .22);
  --ease: cubic-bezier(.2, .8, .3, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- каркас ---------- */
.layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 10px 14px;
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100dvh;
}

.brand { display: flex; gap: 11px; align-items: center; padding: 4px 8px 10px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 40px;
  background: linear-gradient(160deg, #4facfe, #2f7fe0);
  color: #fff; font-weight: 650; font-size: 13px; letter-spacing: .02em;
  box-shadow: 0 2px 8px rgba(47, 127, 224, .35);
}
.brand-title { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: 12.5px; }

.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  color: var(--text); padding: 9px 11px; border-radius: 10px;
  font-size: 14.5px; font-weight: 500;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.sidebar nav a svg { width: 20px; height: 20px; flex: 0 0 20px; opacity: .75; }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a:active { transform: scale(.985); }
.sidebar nav a.active {
  background: var(--accent); color: #fff; box-shadow: 0 2px 10px rgba(51, 144, 236, .32);
}
.sidebar nav a.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 6px 11px 2px; font-size: 13.5px; }

.main {
  padding: 28px 34px 72px;
  max-width: 1180px;
  width: 100%;
  margin-inline: auto;   /* на широких экранах колонка по центру, а не липнет влево */
  position: relative;
}
.main::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(rgba(51, 144, 236, .07) 1px, transparent 1.4px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
}
.main > * { position: relative; z-index: 1; }

/* ---------- типографика ---------- */
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.022em; font-weight: 650; }
h2 { font-size: 18px; margin: 30px 0 12px; letter-spacing: -.015em; font-weight: 600; }
h3 { font-size: 15.5px; margin: 20px 0 10px; letter-spacing: -.008em; font-weight: 600; }
p  { margin: 0 0 10px; text-wrap: pretty; }
.sub { color: var(--muted); margin: 0 0 22px; font-size: 14.5px; max-width: 68ch; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.pre { white-space: pre-wrap; word-break: break-word; }

.flash {
  padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 18px;
  font-size: 14px; border: 1px solid transparent; box-shadow: var(--shadow-1);
}
.flash.ok  { background: var(--ok-soft);  border-color: #cbe9d3; color: #1d6b2f; }
.flash.err { background: var(--bad-soft); border-color: #f6cfcd; color: #a3271f; }

/* ---------- карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-1);
}
.card.tight { padding: 14px 16px; }
.card.accent { border-color: #cfe6fb; background: linear-gradient(180deg, #f7fbff, #fff); }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-1);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.stat .n { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- список как в Telegram ---------- */
.rows { display: flex; flex-direction: column; }
.row-item {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 12px; border-radius: 12px;
  transition: background .15s var(--ease);
}
.row-item + .row-item { box-shadow: inset 0 1px 0 var(--border); }
.row-item:hover { background: var(--surface-2); box-shadow: none; }
.row-item .grow { flex: 1 1 auto; min-width: 0; }
.row-item .title { font-weight: 550; display: flex; align-items: center; gap: 8px; }
.row-item .meta { color: var(--muted); font-size: 13px; }
.row-item .side { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; }

.avatar {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  font-weight: 600; font-size: 17px; letter-spacing: .01em;
  box-shadow: inset 0 -1px 2px rgba(0, 0, 0, .08);
}
.avatar { position: relative; overflow: hidden; }
.avatar img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%; display: block;
}
.avatar.sm { width: 32px; height: 32px; flex: 0 0 32px; font-size: 13px; }
.avatar.lg { width: 56px; height: 56px; flex: 0 0 56px; font-size: 22px; }

/* ---------- формы ---------- */
label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=tel], select, textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 12px; font: inherit;
  transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, select:hover, textarea:hover { background: var(--surface-3); }
input:focus, select:focus, textarea:focus {
  outline: none; background: var(--surface); border-color: var(--accent); box-shadow: var(--ring);
}
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
select.mini { width: auto; padding: 5px 8px; font-size: 13px; border-radius: 8px; }
.rubric-chip { display: inline-flex; align-items: center; gap: 6px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 2px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.row > * > label:first-child { min-height: 21px; display: block; }
.row > * { flex: 1 1 200px; min-width: 0; }
.row .shrink { flex: 0 0 auto; }
.field { margin-bottom: 16px; }
.field > label { color: var(--text); font-size: 14px; font-weight: 550; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; line-height: 1.5; max-width: 76ch; }
.hint b { color: var(--text); font-weight: 600; }

.switchline { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.switchline input[type=checkbox] {
  width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: 0 0 18px;
}
.switchline label, .switchline > span { color: var(--text); font-size: 14px; margin: 0; font-weight: 500; }

/* ---------- кнопки ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--surface-2); color: var(--text); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 9px 16px; font: inherit; font-weight: 550;
  cursor: pointer; text-decoration: none;
  transition: background .16s var(--ease), transform .1s var(--ease), box-shadow .16s var(--ease);
}
button:hover, .btn:hover { background: var(--surface-3); text-decoration: none; }
button:active, .btn:active { transform: scale(.975); }
button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm);
}
button.primary, .btn.primary {
  background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(51, 144, 236, .35);
}
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); }
button.danger, .btn.danger { color: var(--bad); }
button.danger:hover, .btn.danger:hover { background: var(--bad-soft); }
button.small, .btn.small { padding: 6px 12px; font-size: 13.5px; border-radius: 8px; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); }
button.ghost:hover, .btn.ghost:hover { background: var(--accent-soft); }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--muted); font-weight: 550; font-size: 12.5px;
  text-transform: none; letter-spacing: .01em; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover td, table tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: none; }

/* ---------- значки ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 550;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.ok   { background: var(--ok-soft);   color: #1d6b2f; }
.badge.warn { background: var(--warn-soft); color: #8a5b06; }
.badge.bad  { background: var(--bad-soft);  color: #a3271f; }
.badge.info { background: var(--accent-soft); color: #1b6cbf; }
.badge.dim  { background: var(--surface-2); color: var(--muted); }

/* ---------- оценки поста в очереди ---------- */
.scores {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px; margin: 14px 0 4px;
}
.score {
  background: var(--surface-2); border-radius: 12px; padding: 11px 13px;
  transition: background .16s var(--ease);
}
.score:hover { background: var(--surface-3); }
.score-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 12.5px; color: var(--muted);
}
.score-head b { color: var(--text); font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.bar {
  height: 6px; border-radius: 99px; background: #dde1e6;
  margin: 8px 0 6px; overflow: hidden;
}
.bar i {
  display: block; height: 100%; border-radius: 99px; background: var(--accent);
  transition: width .35s var(--ease);
}
.score.ok   .bar i { background: var(--ok); }
.score.warn .bar i { background: var(--warn); }
.score.bad  .bar i { background: var(--bad); }
.score-word { font-size: 12.5px; color: var(--muted); }
.score-word.ok   { color: #1d6b2f; }
.score-word.warn { color: #8a5b06; }
.score-word.bad  { color: #a3271f; }

.metrics {
  display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 8px 0;
}
.metrics b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- пост как сообщение ---------- */
.bubble {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px; padding: 13px 15px;
  box-shadow: var(--shadow-1); white-space: pre-wrap; word-break: break-word;
  font-size: 14.5px; line-height: 1.6;
}
.bubble.original { background: var(--surface-2); border-color: transparent; color: #3b4045; }
.post-text { max-height: 280px; overflow: auto; }

.post-image {
  display: block; max-width: 100%; border-radius: 14px; margin-top: 6px;
  border: 1px solid var(--border); box-shadow: var(--shadow-1);
}
.img-loading {
  padding: 16px; border-radius: 12px; background: var(--surface-2);
  color: var(--muted); font-size: 13.5px;
}
.image-block { margin: 14px 0 4px; }

/* ---------- аналитика ---------- */
.bar-row {
  display: grid; grid-template-columns: 180px 1fr 110px;
  gap: 12px; align-items: center; margin-bottom: 9px;
}
.bar-row .bar-label { font-size: 13.5px; color: var(--text); }
.bar-row .bar-value { font-size: 12.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bar-track {
  display: block; height: 10px; border-radius: 99px; background: var(--surface-2);
  overflow: hidden;
}
.bar-track i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s var(--ease); }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 6px; }
.chart-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.chart-bar {
  background: #cfe0f2; border-radius: 6px 6px 3px 3px; position: relative; overflow: hidden;
  min-height: 3px; transition: height .4s var(--ease);
}
.chart-bar-in {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); border-radius: 0 0 3px 3px;
}
.chart-x {
  font-size: 11px; color: var(--muted-2); text-align: center; margin-top: 6px;
  white-space: nowrap; overflow: hidden;
}

.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* подписи концов шкалы и ориентиры */
.scale-ends {
  display: flex; justify-content: space-between; font-size: 12px; color: var(--muted-2);
  margin: -2px 0 4px;
}
.scale-marks { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted-2); }

/* липкая панель «есть несохранённые изменения» */
.savebar {
  position: fixed; left: 264px; right: 0; bottom: 0; z-index: 20;
  display: none; align-items: center; gap: 12px; justify-content: center;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgba(16, 24, 40, .08);
}
.savebar.show { display: flex; }
.savebar .msg { font-size: 14px; font-weight: 550; }
@media (max-width: 900px) { .savebar { left: 0; } }

.login-body { background: linear-gradient(180deg, #f7f9fc, var(--bg)); }
.login-body .brand-mark { display: grid; }
.center-narrow { max-width: 380px; margin: 12vh auto; padding: 0 16px; }
.login-title { text-align: center; margin-bottom: 6px; }

.empty {
  text-align: center; padding: 34px 20px; color: var(--muted);
}
.empty .big { font-size: 30px; margin-bottom: 8px; }

details summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
details summary:hover { color: var(--text); }
details[open] summary { margin-bottom: 8px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a span { display: none; }
  .sidebar-foot { margin: 0; }
  .main { padding: 20px 16px 60px; }
}
