/* Панель TAX CONSENSUS — в стилистике taxco.uz: Playfair Display + Inter, фото здания, сдержанная палитра */
:root {
  --ink: #2b2b2b;
  --ink-soft: #555;
  --muted: #8a8a8a;
  --line: #e4e4e4;
  --bg: #f6f7f8;
  --card: #fff;
  --accent: #0088cc;
  --accent-soft: rgba(0, 136, 204, .08);
  --ok: #2e7d32;
  --ok-soft: #e8f5e9;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --bad: #c62828;
  --bad-soft: #fdecea;
  --radius: 8px;
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--ink); letter-spacing: .5px; }
h1 { font-size: 2rem; margin: 0 0 18px; }
h2 { font-size: 1.45rem; margin: 0 0 14px; }
h3 { font-size: 1.15rem; margin: 0 0 10px; }
h4 { font-size: 1rem; margin: 16px 0 8px; font-weight: 600; }
p { margin: 0 0 10px; }
ul { margin: 0 0 10px 20px; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
pre { white-space: pre-wrap; background: #fafafa; border: 1px solid var(--line); border-radius: 6px; padding: 12px; }

/* ---------- шапка как на сайте ---------- */
.topbar {
  position: relative; color: #fff; min-height: 150px; display: flex; align-items: flex-end;
  background: #2f3236 url('/static/bg.jpg') center 40% / cover no-repeat;
}
.topbar::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.6)); }
.topbar-inner { position: relative; width: 100%; max-width: 1400px; margin: 0 auto; padding: 22px 32px;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.brand { color: #fff; text-decoration: none !important; }
.brand-title { font-family: var(--serif); font-size: 1.9rem; letter-spacing: 4px; text-transform: uppercase; line-height: 1.1; }
.brand-sub { font-size: 11px; letter-spacing: 2.5px; text-transform: uppercase; opacity: .85; margin-top: 6px; }
.who { display: flex; align-items: center; gap: 14px; font-size: 13px; letter-spacing: .5px; }
.who form { margin: 0; }
.link-btn { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.4); color: #fff; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font: inherit; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.link-btn:hover { background: rgba(255,255,255,.25); }

.nav { background: rgba(240, 240, 240, .97); border-bottom: 1px solid #dedede; position: sticky; top: 0; z-index: 20; }
.nav-inner { max-width: 1400px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; overflow-x: auto;
  scrollbar-width: none; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav a { white-space: nowrap; color: #666; font-size: 12px; font-weight: 500; letter-spacing: 1.2px; text-transform: uppercase;
  padding: 14px 10px; border-bottom: 2px solid transparent; text-decoration: none; }
.nav a:hover { color: #333; }
.nav a.active { color: #222; font-weight: 600; border-bottom-color: #333; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 9px; background: var(--accent);
  color: #fff; font-size: 11px; line-height: 18px; text-align: center; letter-spacing: 0; }

.page { max-width: 1400px; margin: 0 auto; padding: 28px 32px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }

/* ---------- блоки ---------- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.card-accent { border-left: 4px solid var(--accent); }
.card h2, .card h3 { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.stat { font-family: var(--serif); font-size: 2.1rem; line-height: 1; }
.stat-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.list { list-style: none; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid #f0f0f0; display: flex; gap: 10px; align-items: baseline; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted);
  font-weight: 500; padding: 10px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid #f1f1f1; vertical-align: top; }
.table tr:hover td { background: #fbfbfb; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; background: #eee; color: #555; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-info { background: var(--accent-soft); color: var(--accent); }

/* ---------- формы ---------- */
label { display: block; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=search], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #d6d6d6; border-radius: 6px; background: #fff; color: var(--ink); }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 360px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 6px; border: 1px solid #333;
  background: #333; color: #fff; font: inherit; font-size: 13px; font-weight: 500; letter-spacing: .8px; cursor: pointer;
  text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: #111; }
.btn-light { background: #fff; color: #333; border-color: #ccc; }
.btn-light:hover { background: #f4f4f4; }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: #256628; }
.btn-bad { background: #fff; color: var(--bad); border-color: #e3b4b4; }
.btn-bad:hover { background: var(--bad-soft); }
.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }
.inline { display: inline; }
.check { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 14px; margin-right: 14px; }

.flash { margin-bottom: 18px; padding: 12px 16px; border-radius: 6px; background: var(--ok-soft); color: var(--ok); border: 1px solid #c8e6c9; }
.flash-err { background: var(--bad-soft); color: var(--bad); border-color: #f5c6c6; }

.prose p { margin-bottom: 10px; }
.prose h4 { font-family: var(--serif); font-weight: 400; font-size: 1.15rem; }
.prose .table { margin: 10px 0; }
.qbox { white-space: pre-wrap; background: #fafafa; border: 1px solid var(--line); border-radius: 6px; padding: 14px; max-height: 420px; overflow: auto; }
.tg-preview { white-space: pre-wrap; background: #eef6fb; border-radius: 10px; padding: 14px 16px; font-size: 14px; }
.steps { font-size: 13px; color: var(--muted); }
.steps li { margin: 3px 0; }
details summary { cursor: pointer; color: var(--ink-soft); font-size: 13px; letter-spacing: .5px; }

/* ---------- ассистент ---------- */
.chat { display: grid; grid-template-columns: 260px 1fr; gap: 20px; min-height: 60vh; }
.chat-list a { display: block; padding: 9px 10px; border-radius: 6px; color: var(--ink-soft); font-size: 14px; }
.chat-list a.active, .chat-list a:hover { background: var(--accent-soft); color: var(--ink); text-decoration: none; }
.chat-box { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); min-height: 60vh; }
.chat-messages { flex: 1; padding: 22px; overflow-y: auto; max-height: 65vh; }
.msg { max-width: 860px; margin-bottom: 18px; }
.msg-user { margin-left: auto; background: #333; color: #fff; padding: 10px 14px; border-radius: 12px 12px 2px 12px; width: fit-content; max-width: 80%; white-space: pre-wrap; }
.msg-assistant { background: #fafafa; border: 1px solid var(--line); padding: 14px 18px; border-radius: 12px 12px 12px 2px; }
.msg-steps { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.chat-form { border-top: 1px solid var(--line); padding: 14px; display: flex; gap: 10px; }
.chat-form textarea { min-height: 52px; height: 52px; }
.chat-hints { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 22px 14px; }
.hint { font-size: 12px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; color: var(--ink-soft); }
.hint:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- вход ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: #2f3236 url('/static/bg.jpg') center / cover no-repeat; position: relative; }
.login-wrap::before { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.login-card { position: relative; background: #fff; border-radius: 10px; padding: 40px 36px; max-width: 420px; width: 100%; text-align: center; }
.login-card .brand-title { color: #222; font-size: 1.7rem; }
.login-card .brand-sub { color: #777; margin-bottom: 26px; }
.login-card ol { text-align: left; margin: 14px 0 0 18px; font-size: 14px; color: var(--ink-soft); }

/* ---------- адаптив (Mini App в Telegram) ---------- */
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; }
  .chat-list { display: none; }
  .page { padding: 20px 16px 60px; }
  .topbar { min-height: 110px; }
  .topbar-inner { padding: 16px; }
  .brand-title { font-size: 1.35rem; letter-spacing: 3px; }
  .who span { display: none; }
  h1 { font-size: 1.6rem; }
  .card { padding: 18px 16px; }
  .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; }
  .table.keep-cols th, .table.keep-cols td { display: table-cell; }
}
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr 1fr; } }

/* утилиты вместо инлайн-стилей (CSP запрещает style="…") */
a.card { color: inherit; text-decoration: none !important; transition: box-shadow .2s ease, transform .2s ease; }
a.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.07); transform: translateY(-1px); }
.span-2 { grid-column: span 2; }
.filters { margin-bottom: 16px; }
.grow-input { flex: 1; min-width: 220px; }
.w-170 { width: 170px; } .w-220 { max-width: 220px; } .w-240 { width: 240px; } .w-260 { max-width: 260px; }
.pill-big { font-size: 14px; padding: 4px 12px; }
.ol { margin-left: 18px; }
.scroll-box { max-height: 340px; overflow: auto; }
@media (max-width: 860px) {
  .span-2 { grid-column: auto; }
  .w-240, .w-170 { width: 100%; }
}

/* ---------- визуальный редактор (static/editor.js) ---------- */
input.dt-input { width: auto; min-width: 220px; }
.rte { margin: 6px 0 4px; }
.rte textarea.rte-hidden { display: none; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 6px; border: 1px solid #d6d6d6; border-bottom: 0; border-radius: 6px 6px 0 0; background: #fafafa; }
.rte-btn { min-width: 34px; height: 32px; padding: 0 10px; border: 1px solid transparent; border-radius: 5px; background: transparent;
  font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; }
.rte-btn:hover { background: #fff; border-color: #d6d6d6; }
.rte-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.rte-btn-bold { font-weight: 700; }
.rte-btn-italic { font-style: italic; font-family: var(--serif); }
.rte-btn-underline { text-decoration: underline; }
.rte-btn-strikeThrough { text-decoration: line-through; }
.rte-sep { width: 1px; height: 20px; margin: 0 4px; background: #ddd; }
.rte-linkbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border: 1px solid #d6d6d6; border-bottom: 0; background: #fff; }
.rte-linkbar[hidden] { display: none; }
.rte-linkbar input { flex: 1; min-width: 200px; }
.rte-linkbar input.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.rte-area { min-height: 220px; max-height: 70vh; overflow: auto; padding: 14px 16px; border: 1px solid #d6d6d6;
  border-radius: 0 0 6px 6px; background: #fff; line-height: 1.6; outline: none; word-wrap: break-word; }
.rte-md .rte-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rte-area:empty::before { content: attr(data-placeholder); color: #aaa; }
.rte-area p { margin: 0 0 10px; }
.rte-area h4 { font-family: var(--serif); font-weight: 400; font-size: 1.2rem; margin: 18px 0 8px; }
.rte-area ul, .rte-area ol { margin: 0 0 10px 24px; }
.rte-area a { color: var(--accent); text-decoration: underline; }
.rte-area table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 14px; }
.rte-area td, .rte-area th { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.rte-area blockquote { margin: 6px 0; padding: 4px 10px; border-left: 3px solid #3a9ad9; border-radius: 4px; background: rgba(58, 154, 217, .1); }
.rte-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.rte-count { white-space: nowrap; }
.rte-count.warn { color: var(--bad); font-weight: 600; }
/* пост Telegram выглядит как сообщение в канале */
.rte-chat { padding: 16px 14px; border: 1px solid #d6d6d6; border-radius: 0 0 6px 6px; background: #dbe6ee; }
.rte-tg .rte-area { min-height: 160px; border: 0; border-radius: 12px 12px 12px 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
  font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; font-size: 15px; line-height: 1.45; }
.rte-tg .rte-area:focus { box-shadow: 0 0 0 2px var(--accent); }
.rte-tg .rte-area a { color: #168acd; text-decoration: none; }
.tg-spoiler { border-radius: 3px; background: #d0d0d0; }
@media (max-width: 860px) { .rte-meta { flex-direction: column; gap: 2px; } .rte-chat { padding: 10px 8px; } }
/* кнопка входа через Telegram (OpenID Connect) */
.btn-tg { display: flex; justify-content: center; width: 100%; padding: 13px 18px; border-color: #2aabee; background: #2aabee;
  font-size: 15px; letter-spacing: .3px; text-decoration: none !important; }
.btn-tg:hover { border-color: #229ed9; background: #229ed9; }

/* живое обновление: счётчики в меню и подсветка обновившегося блока */
.badge[hidden] { display: none; }
@keyframes live-flash { from { background-color: rgba(0, 136, 204, .10); } to { background-color: transparent; } }
.live-flash { animation: live-flash 1.6s ease-out; }

/* ассистент: кнопка голосового вопроса */
.chat-actions { display: flex; gap: 8px; align-items: stretch; }
.btn-mic { white-space: nowrap; }
.btn-mic.recording { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 4px rgba(198, 40, 40, .15); } }
@media (max-width: 860px) { .chat-form { flex-direction: column; } .chat-actions .btn { flex: 1; justify-content: center; } }

/* подсказки «как этим пользоваться» */
.help { background: #fafafa; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; font-size: 14px; color: var(--ink-soft); }
.help b { color: var(--ink); }
.help ul { margin: 6px 0 0 18px; }
.help li { margin: 3px 0; }
.orig-title { display: block; margin-top: 2px; }
.section-row td { background: #fafafa; font-weight: 600; }
.digest-clip { max-height: 320px; overflow: hidden; position: relative; }
.digest-clip::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 60px; background: linear-gradient(transparent, #fff); }
