:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fafb;
    --ink: #111827;
    --muted: #667085;
    --line: #e5e7eb;
    --primary: #315df6;
    --primary-dark: #2546bd;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --shadow: 0 14px 40px rgba(15, 23, 42, .07);
    --radius-lg: 22px;
    --radius-md: 16px;
}

* { box-sizing: border-box; }
body.app-shell {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 0%, rgba(49, 93, 246, .10), transparent 26rem),
        radial-gradient(circle at 85% 8%, rgba(20, 184, 166, .08), transparent 28rem),
        var(--bg);
    color: var(--ink);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
}

.app-navbar {
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid rgba(229, 231, 235, .9);
    backdrop-filter: blur(18px);
}
.app-nav-inner,
.app-container {
    max-width: 1360px;
    margin: 0 auto;
    padding-left: clamp(1rem, 2.2vw, 2rem);
    padding-right: clamp(1rem, 2.2vw, 2rem);
}
.app-container { padding-top: 1.35rem; padding-bottom: 3rem; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.02em;
}
.brand-mark img { filter: drop-shadow(0 8px 18px rgba(49, 93, 246, .20)); }
.nav-tabs-soft {
    display: flex;
    gap: .18rem;
    padding: .25rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
}
.nav-tabs-soft .nav-link {
    display: inline-flex;
    align-items: center;
    gap: .42rem;
    border: 0;
    color: #475569;
    border-radius: 999px;
    padding: .48rem .78rem;
    font-size: .94rem;
    font-weight: 500;
}
.nav-tabs-soft .nav-link.active,
.nav-tabs-soft .nav-link:hover {
    color: var(--primary);
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
}
.nav-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.btn-ghost, .btn-light-soft {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #334155;
}
.btn-ghost:hover, .btn-light-soft:hover { background: #f8fafc; color: var(--primary); border-color: #c7d2fe; }
.profile-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    max-width: 280px;
    padding: .38rem .6rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    color: #334155;
    font-size: .9rem;
}
.profile-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip b {
    background: #eef2ff;
    color: var(--primary);
    border-radius: 999px;
    padding: .08rem .38rem;
    font-size: .72rem;
    font-weight: 600;
}

.view { display: none; animation: fadeIn .18s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1, h2, h3 { color: var(--ink); letter-spacing: -.025em; }
h1 { font-size: clamp(1.75rem, 2.6vw, 2.65rem); line-height: 1.06; font-weight: 720; margin: .28rem 0 .42rem; }
h2 { font-weight: 650; }
p { color: var(--muted); margin-bottom: 0; }
.eyebrow, .mini-label {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .72rem;
    font-weight: 680;
}
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.compact-head { margin-top: .3rem; }
.shortcut-pills { display: flex; flex-wrap: wrap; gap: .45rem; }
.shortcut-pills span {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .42rem .65rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    color: #64748b;
    font-size: .9rem;
}

.panel-card, .toolbar-card, .table-card, .analytics-card, .documents-list-panel, .pdf-viewer-panel {
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(229, 231, 235, .95);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.panel-card { padding: clamp(1rem, 2vw, 1.3rem); }
.search-workspace {
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
    gap: 1rem;
    align-items: stretch;
}
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.card-title-row h2 { font-size: 1.35rem; margin: .1rem 0 0; }
.question-input { min-height: 430px; font-size: 1.04rem; line-height: 1.58; resize: vertical; }
.answer-input { min-height: 520px; font-size: 1.12rem; line-height: 1.6; resize: vertical; }
.form-control, .form-select, .input-group-text { border-color: #d9dee8; border-radius: 14px; }
.input-group > .input-group-text { border-top-right-radius: 0; border-bottom-right-radius: 0; background: #fff; }
.input-group > .form-control { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .22rem rgba(49, 93, 246, .12); }
.form-label { font-weight: 600; color: #344054; margin-bottom: .38rem; }
.btn { border-radius: 13px; font-weight: 560; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }

.result-stage { min-height: 100%; }
.result-state { min-height: 620px; display: flex; flex-direction: column; justify-content: center; }
.result-state:not(.idle-state) { justify-content: flex-start; }
.idle-state { align-items: center; text-align: center; color: var(--muted); }
.state-illustration { width: 5rem; height: 5rem; display:grid; place-items:center; border-radius: 24px; background: #eef2ff; color: var(--primary); font-size: 2.35rem; margin-bottom: 1rem; }
.answer-found-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 18px; padding: 1rem; margin-bottom: 1rem; }
.answer-found-head.warning { background: #fffbeb; border-color: #fde68a; }
.answer-found-head.danger { background: #fff1f2; border-color: #fecdd3; }
.answer-found-head h2 { margin: .35rem 0 0; font-size: clamp(1.45rem, 2.1vw, 2rem); }
.state-pill { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 680; }
.state-pill.success { color: #15803d; }
.state-pill.warning { color: #b45309; }
.state-pill.danger { color: #be123c; font-size: 1.2rem;}
.score-badge { flex: 0 0 auto; background: #fff; color: var(--success); border: 1px solid #dcfce7; border-radius: 999px; padding: .48rem .68rem; font-weight: 680; }
.score-badge.warning { color: var(--warning); border-color: #fde68a; }
.answer-output {
    background: #fff;
    color: #0f172a;
    border: 1px solid #dbeafe;
    border-left: 5px solid var(--primary);
    border-radius: 20px;
    padding: clamp(1.15rem, 2vw, 1.55rem);
    min-height: 330px;
    max-height: 62vh;
    overflow: auto;
    white-space: pre-wrap;
    font-size: clamp(1.25rem, 1.55vw, 1.55rem);
    line-height: 1.58;
    box-shadow: 0 18px 45px rgba(49, 93, 246, .08);
}
.answer-image { width: 100%; max-height: 340px; object-fit: contain; margin-top: 1rem; border-radius: 18px; background: #f8fafc; border: 1px solid #e2e8f0; }
.answer-meta, .record-hero, .permission-note { color: #667085; font-size: .95rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 16px; padding: .75rem .9rem; margin-top: 1rem; }
.similar-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 18px; padding: 1rem; color: #78350f; margin-bottom: 1rem; }

.toolbar-card { padding: 1rem; }
.toolbar-card.compact { border-radius: 18px; box-shadow: none; padding: .85rem; }
.table-card { overflow: hidden; }
.app-table th { color: #667085; font-size: .78rem; letter-spacing: .055em; text-transform: uppercase; background: #f8fafc; border-bottom: 1px solid #e4e7ec; font-weight: 620; }
.app-table td { padding: .9rem .85rem; border-bottom: 1px solid #edf0f5; }
.app-table tbody tr { cursor: pointer; transition: background .15s ease; }
.app-table tbody tr:hover { background: #f8fbff; }
.table-main { font-weight: 600; color: #101828; max-width: 760px; }
.topic-badge, .status-badge { display:inline-flex; align-items:center; border-radius:999px; padding:.25rem .55rem; background:#eef2ff; color:var(--primary); font-weight:620; font-size:.82rem; }
.status-badge.own { background:#ecfdf3; color:#15803d; }
.status-badge.locked { background:#f1f5f9; color:#64748b; }
.pagination-bar { display:flex; align-items:center; justify-content:center; gap:.75rem; padding:1rem; background:#fff; }
.pagination-bar.small-pad { padding:.65rem; }
.pagination-bar span { color:#667085; font-weight:600; }

.kpi-card { background:#fff; border:1px solid #e4e7ec; border-radius:20px; padding:1rem; min-height:126px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi-card:after { content:""; position:absolute; right:-1.8rem; top:-1.8rem; width:5rem; height:5rem; border-radius:50%; background:#eef2ff; }
.kpi-card i { color: var(--primary); font-size:1.35rem; position:relative; z-index:1; }
.kpi-card div { font-size: clamp(1.75rem, 3vw, 2.55rem); line-height:1; font-weight:680; letter-spacing:-.04em; margin:.65rem 0 .25rem; position:relative; z-index:1; }
.kpi-card span { color:#667085; font-weight:560; position:relative; z-index:1; }
.kpi-card small { display:block; color:#98a2b3; margin-top:.25rem; position:relative; z-index:1; }
.analytics-card { box-shadow: var(--shadow); border: 1px solid #e4e7ec; border-radius: 20px; }
.analytics-card h2 { font-size: 1.15rem; }
.stat-row, .author-row { display:grid; grid-template-columns: 82px 1fr 56px; gap:.75rem; align-items:center; margin:.7rem 0; }
.author-row { grid-template-columns: 1fr 64px; padding:.75rem 0; border-bottom:1px solid #edf0f5; }
.stat-bar { height:10px; border-radius:999px; background:#eef2ff; overflow:hidden; }
.stat-bar i { display:block; height:100%; background:linear-gradient(90deg, var(--primary), #14b8a6); border-radius:999px; }

.answer-canvas { width: min(820px, 100vw) !important; }
.offcanvas-header, .offcanvas-body { padding: 1.25rem; }
.editor-question { min-height: 240px; line-height:1.58; }
.editor-answer { min-height: 420px; line-height:1.6; font-size:1.1rem; }
.image-card { display:grid; grid-template-columns: 180px 1fr; gap:1rem; align-items:center; background:#f8fafc; border:1px solid #e2e8f0; border-radius:18px; padding:1rem; }
.image-card img { width:180px; max-height:140px; object-fit:contain; border-radius:14px; background:#fff; border:1px solid #e2e8f0; }
.app-modal { border:0; border-radius:24px; overflow:hidden; box-shadow: var(--shadow); }

.documents-layout { display:grid; grid-template-columns: minmax(310px, 410px) 1fr; gap:1rem; min-height: calc(100vh - 210px); }
.documents-list-panel, .pdf-viewer-panel { padding: 1rem; }
.documents-list { display:flex; flex-direction:column; gap:.7rem; max-height: calc(100vh - 330px); overflow:auto; padding-right:.15rem; }
.document-item { border:1px solid #e4e7ec; background:#fff; border-radius:18px; padding: .95rem; cursor:pointer; transition:.15s ease; }
.document-item:hover, .document-item.active { border-color:#c7d2fe; background:#f8fbff; transform:translateY(-1px); }
.document-gost { display:inline-flex; align-items:center; gap:.35rem; color:#be123c; background:#fff1f2; border:1px solid #fecdd3; border-radius:999px; padding:.22rem .52rem; font-size:.82rem; font-weight:650; margin-bottom:.55rem; }
.document-item h3 { font-size:1.02rem; margin:0 0 .35rem; font-weight:650; line-height:1.3; }
.document-meta { color:#667085; font-size:.9rem; display:flex; flex-wrap:wrap; gap:.4rem; align-items:center; }
.document-desc { margin-top:.45rem; font-size:.9rem; }
.pdf-viewer-panel { min-height: 680px; display:flex; }
.pdf-empty { margin:auto; text-align:center; color:#667085; }
.pdf-empty i { font-size:4rem; color:#dc2626; }
.pdf-frame { width:100%; min-height: 76vh; border:0; border-radius:18px; background:#fff; }

.user-card { background:#fff; border:1px solid #e4e7ec; border-radius:20px; box-shadow:var(--shadow); padding:1rem; height:100%; }
.user-card .role { display:inline-flex; border-radius:999px; padding:.25rem .55rem; background:#eef2ff; color:var(--primary); font-weight:620; font-size:.82rem; }
.user-card.blocked { opacity:.62; }

.audit-meta-grid { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:.75rem; margin-bottom:1rem; }
.audit-meta { background:#f8fafc; border:1px solid #e2e8f0; border-radius:16px; padding:.85rem; }
.audit-meta small { color:#667085; display:block; margin-bottom:.2rem; }
.audit-meta b { font-weight:650; }
.audit-details { display:grid; grid-template-columns: 1fr 1fr; gap:1rem; }
.audit-json { background:#0f172a; color:#dbeafe; border-radius:16px; padding:1rem; overflow:auto; max-height:420px; font-size:.88rem; }
.audit-object-preview { background:#fff; border:1px solid #e4e7ec; border-radius:16px; padding:1rem; }

@media (max-width: 1199.98px) {
    .nav-tabs-soft { border-radius: 20px; flex-wrap: wrap; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .search-workspace { grid-template-columns: 1fr; }
    .question-input { min-height: 320px; }
    .answer-input { min-height: 440px; }
    .result-state { min-height: auto; }
    .documents-layout { grid-template-columns: 1fr; }
    .documents-list { max-height: 420px; }
    .pdf-viewer-panel { min-height: 520px; }
    .audit-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
    .app-container { padding-top: 1rem; }
    .panel-card, .toolbar-card, .table-card, .analytics-card, .documents-list-panel, .pdf-viewer-panel { border-radius: 18px; }
    h1 { font-size: 1.7rem; }
    .question-input { min-height: 260px; }
    .answer-input, .editor-answer { min-height: 360px; }
    .answer-output { font-size: 1.13rem; min-height: 260px; max-height: none; }
    .image-card { grid-template-columns: 1fr; }
    .image-card img { width:100%; }
    .audit-details, .audit-meta-grid { grid-template-columns: 1fr; }
    .profile-chip span { max-width: 120px; }
    .nav-actions { align-items: stretch; }
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background:
        radial-gradient(circle at 20% 15%, rgba(49,93,246,.16), transparent 30rem),
        radial-gradient(circle at 80% 80%, rgba(20,184,166,.12), transparent 28rem),
        var(--bg);
}
.auth-shell { width: min(100%, 440px); }
.auth-card { border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid #e4e7ec; }
.auth-logo { width: 58px; height: 58px; }

/* Minimal UI tuning */
:root {
    --bg: #f7f8fb;
    --surface: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #e6eaf0;
    --primary: #315df6;
    --primary-dark: #2546bd;
    --shadow: 0 10px 28px rgba(15, 23, 42, .055);
    --radius-lg: 18px;
    --radius-md: 12px;
}
body.app-shell {
    background: var(--bg);
    font-size: 14.5px;
    line-height: 1.5;
    font-weight: 400;
}
.app-nav-inner,
.app-container {
    max-width: 1180px;
}
.app-navbar {
    background: #fff;
    backdrop-filter: none;
}
.brand-mark {
    font-size: 1rem;
    font-weight: 600;
}
.brand-mark img { filter: none; }
.nav-tabs-soft {
    background: transparent;
    border: 0;
    border-radius: 0;
    gap: .15rem;
    padding: 0;
}
.nav-tabs-soft .nav-link {
    border-radius: 10px;
    padding: .45rem .65rem;
    font-size: .9rem;
    font-weight: 400;
    color: #4b5563;
}
.nav-tabs-soft .nav-link.active,
.nav-tabs-soft .nav-link:hover {
    background: #f3f6ff;
    color: var(--primary);
    box-shadow: none;
}
.profile-chip,
.profile-chip b {
    border-radius: 10px;
}
.profile-chip b { font-weight: 500; }

h1 { font-size: clamp(1.45rem, 2vw, 2rem); font-weight: 560; line-height: 1.18; }
h2 { font-weight: 540; }
h3 { font-weight: 520; }
.eyebrow, .mini-label { font-size: .68rem; font-weight: 560; letter-spacing: .07em; }
.page-head { margin-bottom: .85rem; }
.page-head p { font-size: .95rem; }
.panel-card, .toolbar-card, .table-card, .analytics-card, .documents-list-panel, .pdf-viewer-panel {
    box-shadow: var(--shadow);
    border-color: var(--line);
}
.search-workspace {
    grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
}
.card-title-row h2 { font-size: 1.15rem; font-weight: 540; }
.form-label { font-weight: 500; }
.form-control, .form-select, .input-group-text, .btn { border-radius: 10px; }
.form-control-lg, .form-select-lg { min-height: 42px; font-size: .98rem; }
.btn { font-weight: 500; }
.btn-lg { padding: .55rem .85rem; font-size: 1rem; }
.question-input { min-height: 340px; font-size: .98rem; line-height: 1.55; }
.answer-input { min-height: 460px; font-size: 1rem; line-height: 1.58; }
.result-state { min-height: 560px; }
.answer-found-head { border-radius: 14px; padding: .9rem; }
.answer-found-head h2 { font-size: 1.35rem; font-weight: 560; }
.state-pill, .score-badge { font-weight: 560; }
.answer-output {
    min-height: 360px;
    max-height: 58vh;
    font-size: 1.05rem;
    line-height: 1.65;
    border: 1px solid #dbeafe;
    border-left: 4px solid var(--primary);
    border-radius: 16px;
    padding: 1.15rem;
    box-shadow: 0 10px 24px rgba(49, 93, 246, .06);
    background: linear-gradient(180deg, #fff, #fbfdff);
}
.answer-output::selection { background: #dbeafe; }
.answer-meta, .record-hero, .permission-note { font-size: .9rem; border-radius: 12px; }

.app-table { font-size: .92rem; }
.app-table th {
    font-weight: 500;
    font-size: .72rem;
    letter-spacing: .04em;
    color: #778091;
    background: #f9fafb;
}
.app-table td { padding: .72rem .75rem; }
.table-main { font-weight: 400; color: #172033; }
.topic-badge, .status-badge { font-weight: 500; font-size: .78rem; border-radius: 10px; }
.pagination-bar span { font-weight: 400; font-size: .92rem; }

.kpi-card {
    border-radius: 16px;
    min-height: 108px;
    padding: .95rem;
}
.kpi-card:after { display:none; }
.kpi-card i { font-size: 1.1rem; }
.kpi-card div { font-size: clamp(1.45rem, 2.4vw, 2rem); font-weight: 560; margin: .5rem 0 .15rem; }
.kpi-card span { font-weight: 500; }
.analytics-card { border-radius: 16px; }
.analytics-title { display:flex; align-items:center; gap:.5rem; margin-bottom:.75rem; color:var(--primary); }
.analytics-title h2 { font-size:1rem; margin:0; color:var(--ink); font-weight:540; }
.timeline-chart { min-height: 220px; display:flex; align-items:flex-end; gap:3px; padding: .75rem .25rem .25rem; overflow-x:auto; }
.timeline-bar { min-width: 16px; flex:1 0 16px; height: 190px; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; gap:.35rem; }
.timeline-bar i { display:block; width:100%; min-height:2px; background:#315df6; border-radius: 6px 6px 2px 2px; opacity:.82; }
.timeline-bar span { writing-mode: vertical-rl; transform: rotate(180deg); color:#98a2b3; font-size:.68rem; max-height:48px; }
.authors-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap:.35rem .8rem; }
.author-row { grid-template-columns: 1fr auto; padding:.45rem 0; margin:0; }
.stat-row { grid-template-columns: 68px 1fr 44px; font-size:.9rem; }

.answer-canvas { width: min(760px, 100vw) !important; }
.editor-question { min-height: 210px; }
.editor-answer { min-height: 360px; font-size: 1rem; }

.documents-layout { grid-template-columns: minmax(280px, 360px) 1fr; }
.document-item { border-radius: 14px; padding: .85rem; }
.document-gost { border-radius: 10px; font-weight: 500; }
.document-item h3 { font-size: .98rem; font-weight: 500; }
.document-meta { font-size: .82rem; }
.document-detail {
    display:flex;
    justify-content:space-between;
    gap:1rem;
    align-items:flex-start;
    border:1px solid var(--line);
    border-radius:14px;
    padding:.9rem;
    margin-bottom:.85rem;
    background:#fff;
}
.document-detail h2 { font-size:1.05rem; margin:.45rem 0 .15rem; font-weight:540; }
.document-detail p { font-size:.92rem; }
.document-detail-actions { display:flex; flex-wrap:wrap; gap:.5rem; justify-content:flex-end; }
.doc-code { display:inline-flex; background:#fff1f2; color:#be123c; border:1px solid #fecdd3; border-radius:10px; padding:.22rem .5rem; font-size:.82rem; }
.document-name-input { min-height: 140px; resize: vertical; }
.pdf-viewer-panel { min-height: 620px; flex-direction: column; }
.pdf-frame { min-height: 68vh; border-radius:14px; }

.audit-details { grid-template-columns: 1fr 1fr; }
.audit-json { font-size:.8rem; }

@media (max-width: 1199.98px) {
    .app-nav-inner, .app-container { max-width: 100%; }
    .search-workspace { grid-template-columns: 1fr; }
    .question-input { min-height: 260px; }
    .answer-input { min-height: 360px; }
    .result-state { min-height: auto; }
}
@media (max-width: 767.98px) {
    body.app-shell { font-size: 14px; }
    .app-container { padding-left: .85rem; padding-right: .85rem; }
    .panel-card, .toolbar-card, .table-card, .analytics-card, .documents-list-panel, .pdf-viewer-panel { border-radius: 14px; }
    .page-head { gap:.5rem; }
    .question-input { min-height: 220px; }
    .answer-input, .editor-answer { min-height: 320px; }
    .answer-output { font-size: 1rem; min-height: 280px; max-height:none; }
    .document-detail { flex-direction:column; }
    .document-detail-actions { width:100%; justify-content:stretch; }
    .document-detail-actions .btn { flex: 1; }
    .timeline-bar { min-width: 14px; }
}

/* Product polish iteration */
:root {
    --bg: #f3f6fb;
    --surface: rgba(255,255,255,.96);
    --ink: #101828;
    --muted: #697586;
    --line: #e1e7f0;
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --accent: #06b6d4;
    --shadow: 0 18px 50px rgba(16, 24, 40, .075);
    --soft-shadow: 0 8px 28px rgba(16, 24, 40, .055);
}
body.app-shell {
    background:
        radial-gradient(circle at 10% -8%, rgba(79, 70, 229, .13), transparent 36rem),
        radial-gradient(circle at 92% 6%, rgba(6, 182, 212, .10), transparent 32rem),
        var(--bg);
}
.app-nav-inner,
.app-container { max-width: 1280px; }
.app-navbar {
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(226,232,240,.82);
}
.brand-mark { font-weight: 700; letter-spacing: -.02em; }
.main-nav { gap: .25rem; }
.main-nav .nav-link {
    display: inline-flex;
    align-items: center;
    gap: .42rem;
    color: #475467;
    border-radius: 13px;
    padding: .55rem .75rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.main-nav .nav-link:hover,
.main-nav .nav-link.active {
    color: var(--primary);
    background: rgba(79, 70, 229, .08);
    border-color: rgba(79, 70, 229, .12);
}
.app-dropdown { border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: .55rem; }
.app-dropdown .dropdown-item { display:flex; align-items:center; gap:.55rem; border-radius: 10px; padding:.55rem .65rem; }
.user-menu-button {
    display:flex; align-items:center; gap:.55rem;
    background:#fff; border:1px solid var(--line); border-radius:14px;
    color:#344054; box-shadow: var(--soft-shadow); padding:.4rem .6rem .4rem .4rem;
}
.user-avatar { width: 32px; height: 32px; display:grid; place-items:center; border-radius: 11px; background: linear-gradient(135deg, var(--primary), #06b6d4); color:#fff; }
.user-menu-name { max-width: 180px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.page-head h1 { font-weight: 650; }
.page-head p { color: #667085; }
.panel-card, .toolbar-card, .table-card, .analytics-card, .documents-list-panel, .pdf-viewer-panel, .side-filter-card {
    background: var(--surface);
    border: 1px solid rgba(225,231,240,.95);
    box-shadow: var(--shadow);
}
.search-workspace {
    grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr);
    align-items: start;
}
.question-panel, .result-stage { align-self: start; }
.question-input {
    height: 380px;
    min-height: 220px;
    max-height: 72vh;
    resize: vertical;
}
.result-stage { min-height: auto; }
.result-state { min-height: 520px; }
.topic-choice-box {
    border: 1px solid #dbe4f0;
    background: linear-gradient(180deg, #fff, #fbfdff);
    border-radius: 18px;
    padding: .9rem;
}
.topic-choice-box .form-label { color: var(--primary); }
.topic-count-line { color: #697586; font-size: .92rem; margin-top: .7rem; display:flex; gap:.45rem; align-items:center; }
.not-found-card {
    min-height: 440px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1rem;
    padding: clamp(1.2rem, 3vw, 2rem);
    border-radius: 24px;
    text-align: center;
    background:
        radial-gradient(circle at 50% 0%, rgba(79,70,229,.08), transparent 22rem),
        #fff;
}
.not-found-icon { width: 72px; height: 72px; display:grid; place-items:center; border-radius: 24px; background:#eef2ff; color:var(--primary); font-size:2rem; }
.not-found-card h2 { font-size: 1.45rem; margin: .35rem 0 .25rem; }
.not-found-card p { max-width: 460px; }
.answer-output {
    min-height: 320px;
    font-size: 1.03rem;
    border: 1px solid #dce6f5;
    border-left: 0;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    position: relative;
}
.answer-output:before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 5px;
    border-radius: 16px 0 0 16px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
}
.meta-pills, .record-hero { display:flex; flex-wrap: wrap; gap:.5rem; background: transparent; border:0; padding:0; }
.meta-pills span, .record-hero span { display:inline-flex; gap:.35rem; align-items:center; background:#f8fafc; border:1px solid var(--line); border-radius:999px; padding:.38rem .62rem; color:#475467; }
.question-preview-box {
    max-width: 100%;
    overflow: hidden;
}

.question-preview-box #addAnswerQuestionPreview {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
    color: #172033;
    margin-top: .35rem;
}
.modal-answer-input { height: 200px; min-height: 280px; max-height: 55vh; }

.split-layout { display:grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: 1rem; align-items:start; }
.side-filter-card { border-radius: 20px; padding: 1rem; position: sticky; top: 88px; }
.flex-result-card { min-width: 0; }
.app-table th { font-weight: 560; color:#667085; }
.app-table td { vertical-align: top; }
.answers-table .table-main { font-weight: 500; }
.table-sub { margin-top:.25rem; color:#98a2b3; font-size:.86rem; }
.pagination-bar { background:#fff; border-top:1px solid var(--line); gap:.85rem; }
.pagination-bar .btn { width: 42px; height: 42px; display:grid; place-items:center; border-radius:14px; padding:0; }
.pagination-bar span { display:inline-flex; align-items:center; gap:.35rem; color:#667085; }
.pagination-bar span b { color: var(--ink); font-weight: 650; }

.documents-layout { grid-template-columns: minmax(280px, 30%) minmax(0, 70%); gap: 1rem; align-items: start; }
.documents-list-panel { padding: 1rem; border-radius: 22px; }
.doc-search-panel { display:grid; gap:.7rem; margin-bottom:.9rem; }
.doc-controls-row { display:grid; grid-template-columns: 1fr auto; gap:.55rem; }
.doc-view-toggle { width:42px; padding:0; }
.doc-view-toggle.active { color: var(--primary); border-color:#c7d2fe; background:#eef2ff; }
.document-item { position:relative; padding: 1rem 2.8rem 1rem 1rem; border:1px solid var(--line); border-radius:18px; background:#fff; box-shadow: none; }
.document-item:hover { border-color:#c7d2fe; background:#fbfdff; }
.document-item.active { border-color:#a5b4fc; background: linear-gradient(180deg, #f8faff, #fff); box-shadow: 0 10px 26px rgba(79,70,229,.10); }
.document-actions { position:absolute; right:.55rem; top:.55rem; }
.document-gost { font-size:.96rem; color:#be123c; background:#fff1f2; border:1px solid #fecdd3; }
.document-item h3 { line-height: 1.35; font-size:.94rem; font-weight:520; margin:.65rem 0; }
.documents-list.gost-only-view .document-item { padding: 1.1rem 2.8rem 1.1rem 1rem; }
.documents-list.gost-only-view .document-gost { font-size:1.12rem; padding:.35rem .6rem; }
.pdf-viewer-panel { border-radius:22px; min-height: 76vh; padding:.65rem; }
.pdf-frame { min-height: 74vh; border-radius:18px; }

.kpi-layout { grid-template-columns: minmax(250px, 290px) minmax(0, 1fr); }
.kpi-content { min-width:0; }
.kpi-card { background: linear-gradient(180deg, #fff, #fbfdff); border-color:#e0e7ff; }
.kpi-card i { color: var(--primary); }
.kpi-card div { font-weight: 680; }
.line-chart { min-height: 330px; }
.chart-scroll { overflow-x:auto; overflow-y:hidden; }
.line-chart-svg { min-width: 680px; width:100%; height: 300px; display:block; }
.chart-grid { stroke:#edf2f7; stroke-width:1; }
.chart-axis { fill:#8792a2; font-size:10px; }
.chart-value { font-size:11px; font-weight:700; }
.chart-legend { display:flex; flex-wrap:wrap; gap:.55rem 1rem; margin-top:.65rem; color:#475467; font-size:.88rem; }
.chart-legend span { display:inline-flex; align-items:center; gap:.4rem; }
.chart-legend i, .topic-stat-head i { width:.65rem; height:.65rem; border-radius:999px; display:inline-block; }
.topic-distribution { display:grid; gap:.7rem; }
.topic-stat-card { padding:.75rem; border:1px solid var(--line); border-radius:14px; background:#fff; }
.topic-stat-head { display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; margin-bottom:.5rem; }
.topic-stat-head span { display:flex; gap:.45rem; align-items:flex-start; color:#344054; }
.topic-stat-head b { font-weight:650; }
.topic-author-card { border:1px solid var(--line); border-radius:14px; padding:.8rem; background:#fff; }
.topic-author-card h3 { font-size:.96rem; margin-bottom:.6rem; color:#475467; }
.author-row.modern { display:flex; justify-content:space-between; gap:1rem; padding:.38rem 0; border-bottom:1px solid #f1f4f8; }
.author-row.modern:last-child { border-bottom:0; }
.authors-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap:.75rem; }

.audit-layout { grid-template-columns: minmax(250px, 300px) minmax(0,1fr); }
.audit-table .table-main { font-weight:560; }
.audit-time { color:#344054; white-space:nowrap; }
.action-badge { display:inline-flex; align-items:center; gap:.4rem; padding:.32rem .58rem; border-radius:999px; font-size:.82rem; font-weight:560; }
.action-badge.success { color:#027a48; background:#ecfdf3; }
.action-badge.warning { color:#b54708; background:#fffaeb; }
.action-badge.danger { color:#b42318; background:#fef3f2; }
.action-badge.primary { color:#3538cd; background:#eef4ff; }
.audit-json { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-width:100%; }
.audit-meta-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.users-layout { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); }
.users-results { min-width:0; }
.user-card { border-radius:18px; }

@media (max-width: 1199.98px) {
    .split-layout, .kpi-layout, .audit-layout, .users-layout, .documents-layout { grid-template-columns: 1fr; }
    .side-filter-card { position: static; }
    .search-workspace { grid-template-columns: 1fr; }
    .result-state { min-height: auto; }
    .documents-list { max-height: none; }
}
@media (max-width: 767.98px) {
    .question-input { height: 300px; }
    .not-found-card { min-height: 320px; }
    .pdf-viewer-panel, .pdf-frame { min-height: 62vh; }
    .user-menu-name { max-width: 120px; }
}

/* Final polish: unified chips, KPI and GOST cards */
.meta-pills,
.record-hero {
    display: grid !important;
    gap: .65rem !important;
    background: #f8fafc !important;
    border: 1px solid var(--line) !important;
    border-radius: 16px !important;
    padding: .75rem !important;
}
.meta-pills {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
}
.record-hero > div {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: .55rem;
}
.meta-pills .meta-item,
.record-hero .meta-item {
    display: grid !important;
    gap: .12rem !important;
    align-items: start !important;
    color: #344054 !important;
    background: #ffffff !important;
    border: 1px solid #edf0f5 !important;
    border-radius: 12px !important;
    padding: .62rem .72rem !important;
}
.meta-pills .meta-item > span,
.record-hero .meta-item > span {
    display: block !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    color: #98a2b3 !important;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .68rem;
    font-weight: 650;
}
.meta-pills .meta-item > b,
.record-hero .meta-item > b {
    font-size: .95rem;
    line-height: 1.25;
    color: #1d2939;
    font-weight: 560;
}

.answers-table th,
.answers-table td { font-weight: 400; }
.answers-table .topic-badge { font-weight: 520; }
.answers-table .table-main { font-weight: 500; }

.document-item {
    padding: .95rem 4.35rem .95rem 1rem !important;
    overflow: visible;
}
.document-actions.compact-actions {
    position: absolute;
    top: .75rem;
    right: .75rem;
    display: flex;
    gap: .28rem;
    z-index: 2;
}
.icon-action {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border: 1px solid #e4e7ec;
    background: rgba(255,255,255,.92);
    color: #475467;
    border-radius: 10px;
    padding: 0;
    transition: .15s ease;
}
.icon-action:hover { color: var(--primary); border-color: #c7d2fe; background: #f8faff; }
.icon-action.danger { color: #b42318; }
.icon-action.danger:hover { background: #fff1f2; border-color: #fecdd3; }
.document-gost {
    max-width: calc(100% - .8rem);
    font-size: .96rem !important;
    padding: .24rem .52rem !important;
}
.documents-list.gost-only-view .document-item { padding: .95rem 4.35rem .95rem 1rem !important; }
.documents-list.gost-only-view .document-gost { font-size: .96rem !important; padding: .24rem .52rem !important; }
.doc-view-toggle {
    color: #667085;
    border-color: #d9dee8;
    background: #fff;
}
.doc-view-toggle.active {
    color: #fff !important;
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 8px 20px rgba(49, 93, 246, .22);
}

.kpi-content .row.g-3.mt-1 > .col-12 { margin-bottom: .25rem; }
.line-chart { min-height: 350px; }
.line-chart-svg { height: 315px; }
.chart-legend { gap: .45rem .7rem; }
.chart-legend span {
    border: 1px solid #edf0f5;
    background: #fff;
    border-radius: 999px;
    padding: .22rem .48rem;
    font-size: .82rem;
}
.pie-chart-wrap {
    display: grid;
    grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
}
.pie-visual {
    position: relative;
    width: 184px;
    max-width: 100%;
    margin: 0 auto;
}
.pie-visual svg {
    width: 100%;
    display: block;
    filter: drop-shadow(0 10px 20px rgba(15,23,42,.06));
}
.pie-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
    pointer-events: none;
}
.pie-center b {
    font-size: 1.35rem;
    line-height: 1;
    color: #101828;
}
.pie-center span {
    font-size: .72rem;
    color: #98a2b3;
}
.pie-legend {
    display: grid;
    gap: .45rem;
    min-width: 0;
}
.pie-legend-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: .65rem;
    align-items: center;
    padding: .5rem .6rem;
    border: 1px solid #edf0f5;
    border-radius: 12px;
    background: #fff;
}
.pie-legend-row span {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-width: 0;
    color: #344054;
}
.pie-legend-row span i {
    width: .65rem;
    height: .65rem;
    border-radius: 999px;
    flex: 0 0 auto;
}
.pie-legend-row b { color: #101828; font-weight: 620; }
.pie-legend-row em { color: #98a2b3; font-style: normal; font-size: .85rem; }

@media (max-width: 767.98px) {
    .meta-pills,
    .record-hero > div,
    .pie-chart-wrap { grid-template-columns: 1fr; }
    .pie-visual { width: 160px; }
}

@media (min-width: 576px) {
    .found-buttons #openFoundButton {
        flex: 0 0 40%;
    }

    .found-buttons #foundContinueButton {
        flex: 0 0 60%;
    }
}

.answer-output {
    border-left: 1px solid #dce6f5 !important;
}

.answer-output::before {
    display: none !important;
    content: none !important;
}

/* Карточка редактора: убрать большой отступ после заголовка */
.answer-canvas .offcanvas-header {
    padding-bottom: .5rem;
}

.answer-canvas .offcanvas-body {
    padding-top: 0;
}

.answer-canvas .offcanvas-title {
    margin-bottom: 0;
}

/* Блок картинки в редакторе */
.answer-canvas .image-card {
    grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
    overflow: hidden;
}

/* Сама картинка помещается внутрь блока */
.answer-canvas .image-card img {
    width: 100%;
    max-width: 220px;
    height: auto;
    max-height: 160px;
    object-fit: contain;
}

/* Поле выбора файла не вылезает и занимает доступную ширину */
.answer-canvas .image-card > div {
    min-width: 0;
}

.answer-canvas .image-card input[type="file"] {
    width: 100%;
    max-width: 100%;
}

/* Если картинки нет, поле загрузки занимает всю ширину */
.answer-canvas .image-card:has(img.d-none) {
    grid-template-columns: 1fr;
}

.brand-mark img {
    width: 48px !important;
    height: 48px !important;
}

.brand-mark {
    gap: .75rem;
    font-size: 1.08rem;
}

.brand-mark {
    gap: .8rem;
    font-size: 1.35rem !important;
    font-weight: 700;
}

/* Текстовые зоны внутри карточки вопроса */
.answer-canvas .editor-question,
.answer-canvas .editor-answer {
    width: 100%;
    overflow: hidden;
    resize: none;
    min-height: 120px;
    line-height: 1.6;
}

.answer-canvas .editor-question {
    min-height: 110px;
}

.answer-canvas .editor-answer {
    min-height: 150px;
}

.documents-head {
    align-items: center;
}

.documents-head-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex: 0 0 auto;
}

.documents-head-actions .btn {
    width: auto;
    white-space: nowrap;
}

#showUploadDocumentButton {
    min-width: 154px;
}

@media (max-width: 767.98px) {
    .documents-head-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .documents-head-actions .btn {
        width: 100%;
    }
}

.documents-list {
    padding-top: 2px;
}

.document-item.active {
    transform: none;
}

/* Компактнее фильтры документов */
.documents-list-panel {
    padding: .85rem !important;
}

.doc-search-panel {
    gap: .45rem !important;
    margin-bottom: .65rem !important;
}

.doc-search-panel .form-label {
    margin-bottom: .15rem !important;
    font-size: .92rem;
    line-height: 1.2;
}

.doc-search-panel .form-select,
.doc-search-panel .form-control,
.doc-search-panel .btn {
    min-height: 42px;
}

.doc-controls-row {
    gap: .45rem !important;
}

.doc-view-toggle {
    width: 42px !important;
    height: 42px !important;
}

.document-filter-actions {
    gap: .45rem !important;
    margin-top: .25rem;
}

/* если где-то остались bootstrap mb-3 внутри панели */
.doc-search-panel .mb-3 {
    margin-bottom: .45rem !important;
}

/* KPI tabs */
.kpi-tabs {
    gap: .5rem;
}

.kpi-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    border-radius: 12px;
    padding: .55rem .8rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #475467;
    font-weight: 500;
}

.kpi-tabs .nav-link.active {
    background: #eef2ff;
    color: var(--primary);
    border-color: #c7d2fe;
}

/* Apex chart container */
.apex-chart {
    min-height: 340px;
}

/* Leaderboard */
.leaderboard-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: .75rem;
    padding: .75rem .85rem;
    border: 1px solid #edf0f5;
    border-radius: 14px;
    background: #fff;
    margin-bottom: .65rem;
}

.leaderboard-rank {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #eef2ff;
    color: var(--primary);
    font-weight: 700;
}

.leaderboard-name {
    font-weight: 600;
    color: #101828;
}

.leaderboard-sub {
    font-size: .82rem;
    color: #98a2b3;
}

.leaderboard-score {
    font-size: 1.15rem;
    font-weight: 700;
    color: #101828;
}

/* Authors by topic */
.author-topic-grid {
    display: grid;
    gap: .85rem;
}

.author-topic-card {
    border: 1px solid #edf0f5;
    border-radius: 16px;
    background: #fff;
    padding: .9rem;
}

.author-topic-head {
    margin-bottom: .8rem;
}

.author-topic-head h3 {
    margin: .45rem 0 0;
    font-size: 1rem;
    line-height: 1.3;
    font-weight: 600;
    color: #1f2937;
}

.author-topic-list {
    display: grid;
    gap: .55rem;
}

.author-topic-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .55rem .65rem;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #edf0f5;
}

.author-topic-row-left {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
}

.author-topic-rank {
    width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #eef2ff;
    color: var(--primary);
    font-size: .78rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.author-topic-name {
    font-weight: 500;
    color: #344054;
}

/* KPI cards */
#kpiOverviewPane .analytics-card,
#kpiChartsPane .analytics-card,
#kpiAuthorsPane .analytics-card {
    border-radius: 18px;
}

@media (max-width: 767.98px) {
    .leaderboard-item {
        grid-template-columns: 36px minmax(0, 1fr) auto;
    }

    .leaderboard-rank {
        width: 36px;
        height: 36px;
    }
}

/* ===== KPI: аккуратные заголовки карточек ===== */

.kpi-content .analytics-card {
    overflow: hidden;
}

.kpi-content .analytics-card .card-body {
    padding: 1rem !important;
}

.kpi-content .analytics-title {
    display: flex !important;
    align-items: center !important;
    gap: .65rem !important;

    margin: 0 0 1rem 0 !important;
    padding: 0 0 .8rem 0 !important;

    border-bottom: 1px solid #edf0f5;
    color: #101828 !important;
}

.kpi-content .analytics-title i {
    width: 34px;
    height: 34px;
    min-width: 34px;

    display: inline-grid !important;
    place-items: center;

    border-radius: 11px;
    background: #eef2ff;
    color: var(--primary);

    font-size: 1rem;
    line-height: 1;
}

.kpi-content .analytics-title h2 {
    margin: 0 !important;
    padding: 0 !important;

    font-size: 1.08rem !important;
    line-height: 1.25 !important;
    font-weight: 650 !important;
    color: #101828 !important;

    letter-spacing: -.015em;
}

/* Чтобы заголовки во вкладке авторов не прилипали к верхней границе */
#kpiAuthorsPane .analytics-card .card-body,
#kpiChartsPane .analytics-card .card-body,
#kpiOverviewPane .analytics-card .card-body {
    padding-top: 1.05rem !important;
}

/* Чуть больше воздуха между карточками авторов */
#kpiAuthorsPane .row {
    row-gap: 1rem;
}

/* ===== KPI Authors tab redesign ===== */

#kpiAuthorsPane .row {
    align-items: flex-start;
}

#kpiAuthorsPane .analytics-card.h-100 {
    height: auto !important;
}

#kpiAuthorsPane .analytics-card {
    border-radius: 22px;
}

#kpiAuthorsPane .analytics-card .card-body {
    padding: 1.15rem !important;
}

/* Общий топ */
.authors-summary {
    display: grid;
    gap: .75rem;
    margin-bottom: 1rem;
}

.authors-summary-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;

    padding: 1rem;
    border-radius: 18px;
    background:
        radial-gradient(circle at 0% 0%, rgba(79, 70, 229, .14), transparent 15rem),
        #f8faff;
    border: 1px solid #dfe7ff;
}

.authors-summary-main span,
.authors-summary-grid span {
    display: block;
    color: #98a2b3;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 650;
    margin-bottom: .2rem;
}

.authors-summary-main b {
    display: block;
    color: #101828;
    font-size: 1.05rem;
    line-height: 1.25;
}

.authors-summary-main strong {
    flex: 0 0 auto;
    min-width: 58px;
    height: 58px;

    display: grid;
    place-items: center;

    border-radius: 18px;
    background: var(--primary);
    color: #fff;

    font-size: 1.4rem;
    font-weight: 750;
    box-shadow: 0 14px 30px rgba(79, 70, 229, .22);
}

.authors-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

.authors-summary-grid > div {
    padding: .85rem;
    border: 1px solid #edf0f5;
    border-radius: 16px;
    background: #fff;
}

.authors-summary-grid b {
    font-size: 1.25rem;
    color: #101828;
}

/* Рейтинг авторов */
.leaderboard-list {
    display: grid;
    gap: .65rem;
}

.leaderboard-item.modern {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: .8rem;

    padding: .75rem;
    border: 1px solid #edf0f5;
    border-radius: 16px;
    background: #fff;
    margin-bottom: 0;
}

.leaderboard-rank {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;

    border-radius: 14px;
    background: #eef2ff;
    color: var(--primary);

    font-weight: 750;
}

.leaderboard-rank.gold {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}

.leaderboard-meta {
    min-width: 0;
}

.leaderboard-name {
    color: #101828;
    font-weight: 650;
    margin-bottom: .4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-score {
    color: #101828;
    font-size: 1.15rem;
    font-weight: 750;
}

.leaderboard-bar,
.author-topic-bar {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #eef2f7;
}

.leaderboard-bar i,
.author-topic-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), #06b6d4);
}

/* Авторы по темам */
.author-topic-grid.modern {
    display: grid;
    grid-template-columns: 1fr;
    gap: .85rem;
}

.author-topic-card.modern {
    padding: .95rem;
    border: 1px solid #edf0f5;
    border-radius: 18px;
    background: #fff;
}

.author-topic-card.modern:hover {
    border-color: #c7d2fe;
    background: #fbfdff;
}

.author-topic-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: .7rem;

    margin-bottom: .85rem;
}

.author-topic-head .topic-badge {
    margin-top: .05rem;
}

.author-topic-head h3 {
    margin: 0 !important;
    color: #1f2937;
    font-size: 1rem;
    line-height: 1.32;
    font-weight: 650;
}

.author-topic-list {
    display: grid;
    gap: .55rem;
}

.author-topic-row.modern {
    display: grid;
    gap: .45rem;

    padding: .65rem .75rem;
    border-radius: 14px;
    border: 1px solid #edf0f5;
    background: #f8fafc;
}

.author-topic-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.author-topic-row-left {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
}

.author-topic-rank {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;

    border-radius: 10px;
    background: #eef2ff;
    color: var(--primary);

    font-size: .82rem;
    font-weight: 750;
    flex: 0 0 auto;
}

.author-topic-name {
    min-width: 0;
    color: #344054;
    font-weight: 560;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.author-topic-row b {
    color: #101828;
    font-size: 1rem;
    font-weight: 750;
}

@media (max-width: 767.98px) {
    .authors-summary-grid {
        grid-template-columns: 1fr;
    }

    .leaderboard-item.modern {
        grid-template-columns: 38px minmax(0, 1fr) auto;
    }

    .leaderboard-rank {
        width: 38px;
        height: 38px;
    }
}

/* Убрать полоски прогресса во вкладке "Авторы" */
#kpiAuthorsPane .leaderboard-bar,
#kpiAuthorsPane .author-topic-bar {
    display: none !important;
}

/* Чуть выровнять строки после удаления полосок */
#kpiAuthorsPane .leaderboard-name {
    margin-bottom: 0 !important;
}

#kpiAuthorsPane .author-topic-row.modern {
    gap: 0 !important;
}

#kpiAuthorsPane .author-topic-row-top {
    margin-bottom: 0 !important;
}

/* ===== Users cards redesign ===== */

.user-card.modern {
    height: 100%;
    padding: 1.1rem;
    border-radius: 22px;
    border: 1px solid #e4eaf3;
    background:
        radial-gradient(circle at 100% 0%, rgba(79, 70, 229, .06), transparent 12rem),
        #fff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .05);
    transition: .18s ease;
}

.user-card.modern:hover {
    transform: translateY(-2px);
    border-color: #c7d2fe;
    box-shadow: 0 18px 42px rgba(79, 70, 229, .10);
}

.user-card.modern.blocked {
    opacity: .72;
    background:
        linear-gradient(180deg, #fcfcfd, #f8fafc);
}

.user-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .9rem;
    margin-bottom: 1rem;
}

.user-identity {
    display: flex;
    align-items: flex-start;
    gap: .8rem;
    min-width: 0;
}

.user-avatar-box {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #06b6d4);
    color: #fff;
    font-weight: 750;
    font-size: 1rem;
    box-shadow: 0 10px 24px rgba(79, 70, 229, .22);
}

.user-main {
    min-width: 0;
}

.user-main h2 {
    margin: 0 0 .2rem 0;
    font-size: 1.25rem;
    line-height: 1.15;
    font-weight: 700;
    color: #101828;
    word-break: break-word;
}

.user-subline {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .65rem;
    color: #667085;
    font-size: .95rem;
}

.user-subline span {
    position: relative;
}

.user-subline span + span::before {
    content: "•";
    position: absolute;
    left: -.45rem;
    color: #c0c7d4;
}

.user-card.modern .role {
    flex: 0 0 auto;
    padding: .45rem .8rem;
    border-radius: 999px;
    background: #eef2ff;
    color: var(--primary);
    font-size: .88rem;
    font-weight: 650;
    line-height: 1.2;
    max-width: 180px;
    text-align: center;
}

.user-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    margin-bottom: 1rem;
}

.user-meta-item {
    padding: .8rem .9rem;
    border-radius: 16px;
    border: 1px solid #edf0f5;
    background: #f8fafc;
}

.user-meta-item span {
    display: block;
    margin-bottom: .25rem;
    color: #98a2b3;
    font-size: .72rem;
    line-height: 1.2;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.user-meta-item b {
    display: block;
    color: #101828;
    font-size: .98rem;
    line-height: 1.3;
    font-weight: 650;
}

.user-meta-item b.is-active {
    color: #15803d;
}

.user-meta-item b.is-blocked {
    color: #b42318;
}

.user-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem;
    margin-top: auto;
}

.user-actions-grid .btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    border-radius: 12px;
    font-weight: 560;
}

.user-actions-grid .btn[data-user-kpi] {
    grid-column: 1 / -1;
}

@media (max-width: 767.98px) {
    .user-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .user-card.modern .role {
        max-width: none;
        width: fit-content;
    }

    .user-meta-grid {
        grid-template-columns: 1fr;
    }

    .user-actions-grid {
        grid-template-columns: 1fr;
    }

    .user-actions-grid .btn[data-user-kpi] {
        grid-column: auto;
    }
}
/* ===== Fix: нормальные карточки пользователей ===== */

.user-card.modern {
    min-height: auto !important;
    padding: 1rem !important;
    border-radius: 20px !important;
}

/* Шапка карточки: аватар слева, текст справа, роль под текстом */
.user-card.modern .user-card-head {
    display: grid !important;
    grid-template-columns: 56px minmax(0, 1fr) !important;
    grid-template-areas:
        "avatar main"
        "avatar role" !important;
    align-items: start !important;
    gap: .35rem .85rem !important;
    margin-bottom: 1rem !important;
}

/* Разбираем user-identity, чтобы аватар и текст нормально попали в grid */
.user-card.modern .user-identity {
    display: contents !important;
}

.user-card.modern .user-avatar-box {
    grid-area: avatar !important;
    width: 56px !important;
    height: 56px !important;
    border-radius: 16px !important;
}

/* Имя и логин */
.user-card.modern .user-main {
    grid-area: main !important;
    min-width: 0 !important;
}

.user-card.modern .user-main h2 {
    margin: 0 0 .25rem !important;

    font-size: 1.2rem !important;
    line-height: 1.2 !important;
    font-weight: 700 !important;

    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
}

.user-card.modern .user-subline {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: .35rem .65rem !important;

    color: #667085 !important;
    font-size: .92rem !important;
}

/* Роль больше не стоит справа от имени */
.user-card.modern .role {
    grid-area: role !important;

    width: fit-content !important;
    max-width: 100% !important;
    margin: .15rem 0 0 !important;

    padding: .35rem .65rem !important;
    border-radius: 999px !important;

    font-size: .82rem !important;
    line-height: 1.2 !important;
    font-weight: 650 !important;

    white-space: normal !important;
    text-align: left !important;
}

/* Метаданные компактнее */
.user-card.modern .user-meta-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: .65rem !important;
    margin-bottom: .9rem !important;
}

.user-card.modern .user-meta-item {
    padding: .7rem .75rem !important;
    border-radius: 14px !important;
}

.user-card.modern .user-meta-item span {
    font-size: .68rem !important;
}

.user-card.modern .user-meta-item b {
    font-size: .92rem !important;
    line-height: 1.25 !important;
}

/* Кнопки аккуратной сеткой */
.user-card.modern .user-actions-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: .55rem !important;
}

.user-card.modern .user-actions-grid .btn {
    min-height: 40px !important;
    padding: .45rem .6rem !important;
    border-radius: 12px !important;
    font-size: .95rem !important;
}

.user-card.modern .user-actions-grid .btn[data-user-kpi] {
    grid-column: 1 / -1 !important;
}

/* Чтобы карточки не становились огромными */
.users-results .user-card.modern {
    height: auto !important;
}

@media (max-width: 767.98px) {
    .user-card.modern .user-card-head {
        grid-template-columns: 48px minmax(0, 1fr) !important;
    }

    .user-card.modern .user-avatar-box {
        width: 48px !important;
        height: 48px !important;
    }

    .user-card.modern .user-meta-grid,
    .user-card.modern .user-actions-grid {
        grid-template-columns: 1fr !important;
    }

    .user-card.modern .user-actions-grid .btn[data-user-kpi] {
        grid-column: auto !important;
    }
}