/* Стили, специфичные для RS Console. Основа — rs-ui.css (общая дизайн-система, копируется при сборке). */
button.list-item:hover { background: var(--surface-2); }

/* ---------- Почта ---------- */
.mail { display: grid; grid-template-columns: 190px minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.mail-folders { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 84px; }
.mail-folder { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: none; color: var(--muted); font: 500 14px/1.3 var(--font-body); text-align: left; cursor: pointer; }
.mail-folder svg { width: 17px; height: 17px; flex-shrink: 0; }
.mail-folder:hover { background: var(--surface); color: var(--text); }
.mail-folder[aria-current="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--volt); }
.mail-folder-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-count { font: 600 12px/1 var(--font-mono); color: var(--muted); }
.mail-count.is-volt { color: var(--bg); background: var(--volt); padding: 4px 7px; border-radius: 999px; }

.mail-list { overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - 200px); position: sticky; top: 84px; }
.mail-search { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--dim); }
.mail-search svg { width: 17px; height: 17px; flex-shrink: 0; }
.mail-search input { flex: 1; min-width: 0; background: none; border: 0; color: var(--text); font: 400 14px/1.4 var(--font-body); padding: 6px 0; }
.mail-search input:focus { outline: none; }
.mail-search input::placeholder { color: var(--dim); }
.mail-spinner { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--volt); border-radius: 50%; animation: rs-spin .7s linear infinite; }
@keyframes rs-spin { to { transform: rotate(360deg); } }
.mail-rows { overflow-y: auto; flex: 1; }
.mail-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); position: relative; }
.mail-row:hover { background: var(--surface-2); }
.mail-row.is-active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--volt); }
.mail-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 12px 4px 12px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.mail-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mail-row-from { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row-from .dot { width: 7px; height: 7px; box-shadow: none; }
.mail-row-date { font: 500 12px/1 var(--font-mono); color: var(--dim); flex-shrink: 0; }
.mail-row-subject { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row-ico { width: 13px; height: 13px; flex-shrink: 0; color: var(--dim); }
.mail-row.is-unread .mail-row-from { color: var(--text); font-weight: 600; }
.mail-row.is-unread .mail-row-subject { color: var(--text-2); }
.mail-star { width: 40px; flex-shrink: 0; border: 0; background: none; color: var(--line-2); cursor: pointer; display: grid; place-items: center; }
.mail-star svg { width: 16px; height: 16px; }
.mail-star:hover { color: var(--muted); }
.mail-star.is-on { color: var(--warn); }
.mail-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }

.mail-reader { min-height: 420px; overflow: hidden; }
.mail-placeholder { min-height: 420px; justify-content: center; }
.mail-reader-bar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.mail-actions { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mail-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.mail-back { display: none; margin-right: auto; }
.mail-head { padding: 22px 24px 16px; display: flex; flex-direction: column; gap: 16px; }
.mail-head h2 { font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.mail-from { display: flex; align-items: center; gap: 12px; }
.mail-from .list-sub { white-space: normal; }
.mail-date { flex-shrink: 0; align-self: flex-start; }
.mail-remote { display: flex; align-items: center; gap: 12px; margin: 0 24px 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.mail-remote svg { width: 18px; height: 18px; flex-shrink: 0; }
.mail-remote span { flex: 1; }
.mail-frame { display: block; width: calc(100% - 48px); margin: 0 24px; min-height: 160px; border: 0; border-radius: var(--radius); background: #fff; }
.mail-files { padding: 20px 24px 0; display: flex; flex-direction: column; gap: 10px; }
.mail-file-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.mail-file { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.mail-file:hover { border-color: var(--line-2); color: var(--text); }
.mail-file svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted); }
.mail-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 20px 24px 24px; }

.mail-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: flex-end; padding: 24px; background: rgba(5, 6, 8, .55); backdrop-filter: blur(2px); }
.mail-compose { width: min(680px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.mail-compose-body { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
.mail-line { display: flex; align-items: center; gap: 12px; padding: 4px 16px 4px 24px; border-bottom: 1px solid var(--line); }
.mail-line label { width: 64px; flex-shrink: 0; font: 500 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.mail-line input { flex: 1; min-width: 0; min-height: 44px; background: none; border: 0; color: var(--text); font: 400 15px/1.4 var(--font-body); }
.mail-line input:focus { outline: none; }
.mail-line:focus-within { box-shadow: inset 2px 0 0 var(--volt); }
.mail-line-error { padding: 6px 24px 0; }
.mail-textarea { flex: 1; min-height: 260px; padding: 18px 24px; background: none; border: 0; resize: vertical; color: var(--text); font: 400 15px/1.6 var(--font-body); }
.mail-textarea:focus { outline: none; }
.mail-textarea::placeholder { color: var(--dim); }
.mail-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 24px 12px; }
.mail-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 6px 6px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; max-width: 100%; }
.mail-chip svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted); }
.mail-chip button { border: 0; background: none; color: var(--dim); cursor: pointer; padding: 2px; border-radius: 6px; }
.mail-chip button:hover { color: var(--text); background: var(--surface-3); }
.mail-compose-note { padding: 0 24px 14px; font-size: 12px; color: var(--dim); }
.mail-sig-preview { overflow-x: auto; }
.mail-sig-preview > table { margin-top: 0 !important; }

@media (max-width: 1500px) {
  .mail { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .mail-folders { grid-column: 1 / -1; position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .mail-folder { width: auto; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .mail { grid-template-columns: 1fr; }
  .mail-folders { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .mail-folder { flex-shrink: 0; }
  .mail-list { position: static; max-height: none; }
  .mail.is-reading .mail-list, .mail.is-reading .mail-folders { display: none; }
  .mail:not(.is-reading) .mail-reader { display: none; }
  .mail-back { display: inline-flex; }
  .mail-reader-bar { flex-wrap: wrap; padding: 10px 12px; }
  .mail-head { padding: 18px 16px 14px; }
  .mail-frame { width: calc(100% - 24px); margin: 0 12px; }
  .mail-remote { margin: 0 12px 12px; }
  .mail-files, .mail-quick { padding-left: 16px; padding-right: 16px; }
  .mail-overlay { padding: 0; align-items: stretch; }
  .mail-compose { width: 100%; max-height: none; height: 100%; border-radius: 0; }
  .mail-line { padding-left: 16px; }
  .mail-textarea { padding: 16px; }
}

/* ---------- RS Mail (mail.rsdevelopment.net) ---------- */
.webmail { min-height: 100vh; display: flex; flex-direction: column; }
.webmail-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 28px; background: rgba(11, 13, 16, .88); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.webmail-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.webmail-user form { flex-shrink: 0; }
.webmail-email { max-width: 260px; }
.webmail-main { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; padding: 24px 28px 32px; }
.mail-page-head { align-items: center; }
.mail-page-head h1 { font-size: 28px; }
.webmail .mail-folders, .webmail .mail-list { top: 84px; }
@media (max-width: 860px) {
  .webmail-top { padding: 10px 16px; }
  .webmail-main { padding: 16px 16px 24px; }
  .mail-page-head h1 { font-size: 24px; }
}
@media (max-width: 520px) {
  .webmail-email, .webmail-logout-label { display: none; }
  .webmail-user .avatar { display: none; }
}
.mail-date-inline { display: none; }
@media (max-width: 860px) {
  .mail-reader-bar { flex-wrap: nowrap; gap: 6px; }
  .mail-actions { flex-wrap: nowrap; gap: 4px; overflow-x: auto; }
  .mail-actions .btn-label, .mail-sep { display: none; }
  .mail-actions .btn-subtle { width: 36px; padding: 0; }
  .mail-from { align-items: flex-start; }
  .mail-date { display: none; }
  .mail-date-inline { display: block; }
  .mail-head h2 { font-size: 20px; }
}

/* ---------- Заявки и шапка на телефоне ---------- */
.req-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.req-date { min-width: 96px; text-align: right; }
@media (max-width: 640px) {
  .topbar-tagline { display: none; }
  .req-row { flex-wrap: wrap; align-items: flex-start; }
  .req-row .list-main { flex: 1 1 calc(100% - 50px); }
  .req-meta { width: 100%; padding-left: 48px; }
  .req-date { min-width: 0; margin-left: auto; }
}

/* ---------- Лиды ---------- */
.stat-link { color: inherit; transition: border-color .15s; }
.stat-link:hover { color: inherit; border-color: var(--line-2); }
.leads-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.leads-tabs .mail-folder { width: auto; flex-shrink: 0; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); }
.leads-tabs .mail-folder[aria-current="true"] { background: var(--surface-2); border-color: var(--line-2); box-shadow: inset 0 -2px 0 var(--volt); }
.mail.leads { grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); }
.leads-src { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text-2); font: 500 12px/1 var(--font-body); padding: 7px 8px; max-width: 140px; }
.leads-row-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.leads-row-meta .chip { display: inline-flex; align-items: center; gap: 5px; }
.leads-row-meta .badge { padding: 3px 8px; font-size: 11px; }
.leads-status { display: flex; flex-wrap: wrap; gap: 6px; }
.leads-status-btn { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: none; color: var(--muted); font: 500 13px/1 var(--font-body); cursor: pointer; }
.leads-status-btn:hover { color: var(--text); border-color: var(--muted); }
.leads-status-btn[aria-pressed="true"] { background: var(--volt); border-color: var(--volt); color: var(--bg); }
.leads-status-btn[aria-pressed="true"][data-status="won"] { background: var(--ok); border-color: var(--ok); }
.leads-status-btn[aria-pressed="true"][data-status="lost"] { background: var(--err); border-color: var(--err); }
.leads-status-btn[aria-pressed="true"][data-status="skipped"] { background: var(--surface-3); border-color: var(--line-2); color: var(--text-2); }
.leads-message { margin: 0 24px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); max-height: 360px; overflow-y: auto; }
.leads-keyword { margin: 10px 24px 0; }
.leads-form { padding: 22px 24px 0; }
.leads-notes { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.leads-note-form { display: flex; flex-direction: column; gap: 8px; }
.leads-timeline { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.leads-timeline li { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 10px 0 10px 18px; border-left: 1px solid var(--line-2); margin-left: 4px; }
.leads-timeline li::before { content: ""; position: absolute; left: -4px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.leads-timeline li.is-note::before { background: var(--volt); }
.leads-timeline li.is-status::before { background: var(--info); }
.leads-timeline-meta { font: 500 11px/1.2 var(--font-mono); letter-spacing: .06em; color: var(--dim); }
.leads-timeline-body { font-size: 14px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.leads-timeline li.is-system .leads-timeline-body, .leads-timeline li.is-status .leads-timeline-body { color: var(--muted); font-size: 13px; }
@media (max-width: 1100px) {
  .mail.leads { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .mail.leads { grid-template-columns: 1fr; }
  .leads-message { margin: 0 16px; }
  .leads-keyword { margin: 10px 16px 0; }
  .leads-form, .leads-notes { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Бот ---------- */
.bot-log { max-height: 560px; overflow: auto; padding: 8px 0; font: 12.5px/1.55 var(--font-mono); }
.bot-log-line { display: flex; gap: 14px; padding: 2px 24px; color: var(--text-2); }
.bot-log-line:hover { background: var(--surface-2); }
.bot-log-line.is-err { color: var(--err); background: var(--err-soft); }
.bot-log-time { color: var(--dim); flex-shrink: 0; }
.bot-log-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.bot-groups { max-height: 420px; overflow-y: auto; border-top: 1px solid var(--line); }
.bot-group { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--line); font-size: 14px; }
.bot-group:last-child { border-bottom: none; }
.bot-group a { color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-group a:hover { color: var(--volt); }
.bot-ad { display: flex; flex-direction: column; }
.bot-ad .card-body { flex: 1; }
.bot-ad-text { white-space: pre-wrap; color: var(--text-2); font-size: 14px; max-height: 220px; overflow: auto; overflow-wrap: anywhere; }
.bot-progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bot-progress span { display: block; height: 100%; background: var(--volt); border-radius: inherit; transition: width .4s; }
@media (max-width: 520px) {
  .bot-log-line { flex-direction: column; gap: 0; padding: 4px 16px; }
  .bot-group { padding: 10px 16px; }
}

/* ---------- RS Console в Telegram (Mini App) ---------- */
.tg-app { min-height: 100vh; display: flex; flex-direction: column; }
.tg-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: rgba(11, 13, 16, .92); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.tg-top .logo { font-size: 16px; }
.tg-main { flex: 1; width: 100%; padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 20px; }
.tg-tabs { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(11, 13, 16, .96); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tg-tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px; border-radius: 12px; color: var(--muted); font: 500 11px/1.2 var(--font-body); }
.tg-tab svg { width: 22px; height: 22px; }
.tg-tab:hover { color: var(--text); }
.tg-tab[aria-current="page"] { color: var(--volt); background: var(--surface); }
.tg-tab-count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; padding: 2px 5px; border-radius: 999px; background: var(--volt); color: var(--bg); font: 700 10px/1.2 var(--font-mono); text-align: center; }
/* Внутри Telegram страницы всегда в «мобильном» виде */
.tg-main .page-head h1 { font-size: 24px; }
.tg-main .page-head p { display: none; }
.tg-main .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tg-main .grid-main, .tg-main .grid-3, .tg-main .grid-2 { grid-template-columns: 1fr; }
.tg-main .stat { padding: 16px; }
.tg-main .stat-value { font-size: 26px; }
.tg-main .mail { grid-template-columns: 1fr; }
.tg-main .mail-list { position: static; max-height: none; }
.tg-main .mail.is-reading .mail-list { display: none; }
.tg-main .mail:not(.is-reading) .mail-reader { display: none; }
.tg-main .mail-back { display: inline-flex; }
.tg-main .mail-overlay { padding: 0; align-items: stretch; }
.tg-main .mail-compose { width: 100%; max-height: none; height: 100%; border-radius: 0; }
.tg-main .card-head, .tg-main .card-body, .tg-main .list-item { padding-left: 16px; padding-right: 16px; }
