/* ЧГТРК «Грозный» — панель вопросов. Светлая тема по умолчанию, тёмная по настройке системы. */
:root {
  color-scheme: light;
  --bg: #f2f3ef;
  --surface: #ffffff;
  --surface-2: #f6f7f3;
  --text: #111a14;
  --text-2: #4f5852;
  --muted: #868d88;
  --line: #e6e8e2;
  --shadow: 0 1px 2px rgba(17, 26, 20, .04), 0 4px 16px rgba(17, 26, 20, .04);

  --lime: #c6f182;
  --lime-2: #a8e35f;
  --on-lime: #0f2418;
  --primary: #12382a;
  --on-primary: #ffffff;
  --link: #176b3f;
  --danger: #c2362f;

  /* графики: один цвет на серию, проверен на контраст и различимость */
  --series: #178a4c;
  --track: #eceee8;
  --grid: #eceee8;

  /* статусы: всегда вместе с подписью */
  --s-new: #868d88;
  --s-selected: #2a78d6;
  --s-aired: #178a4c;
  --s-rejected: #c2362f;
  --warn: #9a5b00;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d110f;
    --surface: #171c19;
    --surface-2: #1e2420;
    --text: #eef1ec;
    --text-2: #b4bbb5;
    --muted: #8a928c;
    --line: #2a312c;
    --shadow: none;
    --primary: #c6f182;
    --on-primary: #0f2418;
    --link: #8fd96a;
    --danger: #f07a72;
    --series: #26a862;
    --track: #252c27;
    --grid: #252c27;
    --s-new: #8a928c;
    --s-selected: #3987e5;
    --s-aired: #26a862;
    --s-rejected: #f07a72;
    --warn: #f0b34a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.mt { margin-top: 12px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 0 6px 14px; }
.logo b { display: block; font-size: 15px; }
.logo small { display: block; color: var(--muted); font-size: 12px; }
.logo-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--lime); color: var(--on-lime); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.logo-mark.big { width: 52px; height: 52px; border-radius: 16px; font-size: 26px; }
.me { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); margin-bottom: 10px; }
.me b { display: block; font-size: 13.5px; }
.me small { display: block; color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 10px 4px; }
.menu { display: grid; gap: 2px; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; color: var(--text-2); font-weight: 500; }
.menu a:hover { background: var(--surface-2); color: var(--text); }
.menu a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.side-card { margin-top: auto; background: var(--surface); border-radius: 18px; padding: 16px; text-align: center; box-shadow: var(--shadow); display: grid; gap: 6px; justify-items: center; }
.side-card p { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.side-card-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--lime); color: var(--on-lime); display: grid; place-items: center; }

.main { min-width: 0; padding: 16px 24px 32px 8px; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 4px 20px; }
.page-title { flex: 1; min-width: 0; }
.page-title h1 { font-size: 24px; font-weight: 700; }
.page-title p { color: var(--muted); font-size: 13px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 12px; padding: 0 12px; box-shadow: var(--shadow); color: var(--muted); width: 280px; }
.search input { border: 0; background: transparent; padding: 10px 0; width: 100%; box-shadow: none; }
.search input:focus { outline: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); }
.icon-btn:hover { color: var(--text); }
.content { display: grid; gap: 16px; }
.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }

/* ---------- элементы ---------- */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
input:focus, select:focus { outline: 2px solid var(--lime-2); outline-offset: 0; border-color: transparent; }
.btn, button { font: inherit; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 11px; padding: 8px 14px; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.btn.dark { background: var(--primary); color: var(--on-primary); }
.btn.dark:hover { filter: brightness(1.15); }
.btn.light { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn.light:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.danger { background: transparent; border-color: var(--line); color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 9px; }
.btn.full { width: 100%; }
.btn .ico { width: 16px; height: 16px; }
button:disabled { opacity: .5; cursor: default; }
.flash { background: var(--lime); color: var(--on-lime); padding: 10px 14px; border-radius: 12px; font-weight: 500; }

.card { background: var(--surface); border-radius: 20px; padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.chip { background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); padding: 2px 10px; border-radius: 999px; font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .6); color: var(--on-lime); padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.pill.live i { width: 8px; height: 8px; border-radius: 50%; background: #0f7a3d; box-shadow: 0 0 0 3px rgba(15, 122, 61, .2); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(15, 122, 61, 0); } }
@media (prefers-reduced-motion: reduce) { .pill.live i { animation: none; } }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.s-new { background: var(--s-new); }
.dot.s-selected { background: var(--s-selected); }
.dot.s-aired { background: var(--s-aired); }
.dot.s-rejected { background: var(--s-rejected); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-size: 12.5px; white-space: nowrap; }

/* ---------- обзор ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-8 { grid-column: span 8; }

.hero { background: radial-gradient(120% 140% at 100% 0%, var(--lime-2) 0%, var(--lime) 55%); color: var(--on-lime); display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 220px; height: 220px; border-radius: 50%; border: 28px solid rgba(255, 255, 255, .25); pointer-events: none; }
.hero-head { display: flex; gap: 6px; margin-bottom: 4px; }
.hero-sub { color: rgba(15, 36, 24, .72); font-size: 13px; }
.hero-num { font-size: 44px; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }
.hero-num small { font-size: 16px; font-weight: 600; }
.hero-title { font-size: 20px; font-weight: 700; line-height: 1.25; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 12px; position: relative; z-index: 1; }
.hero .btn.dark { background: #12382a; color: #fff; }
.hero .btn.light { background: rgba(255, 255, 255, .85); border-color: transparent; color: var(--on-lime); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { display: grid; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; color: var(--text); }
.stat:hover { border-color: var(--muted); }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.stat b { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }

.big-num { font-size: 40px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.meter { height: 10px; border-radius: 999px; background: var(--track); overflow: hidden; margin: 12px 0 14px; }
.meter span { display: block; height: 100%; background: var(--series); border-radius: 999px; }
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mini-list li { display: flex; justify-content: space-between; color: var(--text-2); font-size: 13px; }
.mini-list b { color: var(--text); }

/* столбчатый график */
.chart { display: grid; grid-template-columns: 28px minmax(0, 1fr); grid-template-rows: 220px auto; column-gap: 8px; }
.y-axis { position: relative; }
.y-axis span { position: absolute; right: 0; transform: translateY(50%); font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plot { position: relative; border-bottom: 1px solid var(--line); }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--grid); }
.bars { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; outline: none; }
.bar { width: min(60%, 26px); min-height: 2px; background: var(--series); border-radius: 4px 4px 0 0; transition: filter .15s; }
.col:hover .bar, .col:focus .bar { filter: brightness(1.15); }
.col:hover::before, .col:focus::before { content: ""; position: absolute; inset: 0 2px; background: var(--surface-2); border-radius: 8px; z-index: -1; }
.col:hover::after, .col:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% - 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--surface); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 8px; white-space: nowrap; z-index: 2; pointer-events: none;
}
.bars { z-index: 0; }
.x-axis { grid-column: 2; display: flex; padding-top: 6px; }
.x-axis span { flex: 1; text-align: center; font-size: 11.5px; color: var(--muted); }
.tableview { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.tableview summary { cursor: pointer; }
.tableview .table { margin-top: 8px; }

/* рейтинги (темы, районы) */
.ranks { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.ranks a { display: flex; justify-content: space-between; gap: 10px; color: var(--text); font-size: 13.5px; margin-bottom: 5px; }
.ranks a:hover .rank-name { text-decoration: underline; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranks b { font-variant-numeric: tabular-nums; }
.rank-track { display: block; height: 6px; background: var(--track); border-radius: 999px; overflow: hidden; }
.rank-track span { display: block; height: 100%; background: var(--series); border-radius: 999px; min-width: 6px; }

/* таблицы */
.table-wrap { overflow-x: auto; }
.table-card { padding: 6px 8px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table.compact th, .table.compact td { padding: 4px 6px; text-align: center; }
.table .clip { max-width: 320px; }
.table.fixed { table-layout: fixed; min-width: 620px; }
.table.fixed td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .cut { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td { font-size: 13.5px; }
.table .clip a { color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tr.off td { opacity: .5; }
.empty { color: var(--muted); padding: 32px; text-align: center; }

/* ---------- вопросы ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; }
.toolbar input[type=search] { min-width: 200px; }
.q-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.topics { position: sticky; top: 16px; padding: 16px; }
.topic { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 10px; color: var(--text-2); font-size: 13.5px; }
.topic b { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.topic:hover { background: var(--surface-2); }
.topic.on { background: var(--lime); color: var(--on-lime); font-weight: 600; }
.topic.on b { color: var(--on-lime); }
.q { margin-bottom: 12px; border-left: 4px solid transparent; }
.q.status-selected { border-left-color: var(--s-selected); }
.q.status-aired { border-left-color: var(--s-aired); }
.q.status-rejected { opacity: .55; }
.q-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 13px; }
.q-head select { font-size: 13px; padding: 5px 8px; border-radius: 9px; }
.num { font-weight: 700; }
.q-text { white-space: pre-wrap; margin-top: 10px; font-size: 15px; line-height: 1.55; }
.q-media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.q-media img, .q-media video { height: 140px; max-width: 260px; border-radius: 12px; object-fit: cover; background: #000; display: block; }
.q-contact { margin-top: 10px; font-size: 13px; color: var(--warn); }
.saved { box-shadow: 0 0 0 2px var(--series); }
.pager { display: flex; gap: 6px; flex-wrap: wrap; }
.pager a, .pager b { min-width: 34px; text-align: center; padding: 6px 10px; border-radius: 10px; background: var(--surface); }
.pager b { background: var(--primary); color: var(--on-primary); }

/* ---------- эфиры, пользователи ---------- */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.grid-form h3 { grid-column: 1 / -1; }
.grid-form .wide { grid-column: span 2; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12.5px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.inline-edit { display: grid; gap: 6px; margin: 8px 0; }
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
.state { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.state-open { background: var(--lime); color: var(--on-lime); border-color: transparent; font-weight: 600; }
.state-open::before { background: #0f7a3d; }
.state-scheduled::before { background: var(--s-selected); }
.roles-help { font-size: 13px; }

.login { width: 340px; display: grid; gap: 12px; justify-items: stretch; padding: 28px; }
.login .logo-mark { justify-self: start; }
.login h1 { font-size: 22px; }

/* ---------- адаптив ---------- */
@media (max-width: 1200px) {
  .span-3, .span-4, .span-5 { grid-column: span 6; }
  .hero { grid-column: span 12; }
  .span-8 { grid-column: span 12; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; overflow-x: auto; gap: 4px; }
  .logo { padding: 0 8px 0 0; }
  .logo span:last-child, .me, .menu-label, .side-card { display: none; }
  .menu { display: flex; }
  .menu a { padding: 8px 10px; white-space: nowrap; }
  .main { padding: 0 16px 24px; }
  .topbar { flex-wrap: wrap; padding-bottom: 12px; }
  .search { width: 100%; order: 3; }
  .grid > * { grid-column: span 12 !important; }
  .q-layout { grid-template-columns: 1fr; }
  .topics { position: static; }
  .grid-form .wide { grid-column: auto; }
  .table .clip { max-width: 180px; }
}
