/* ================================================================
   Гермес-НТР — Главные стили
   Тёмный графит + фирменный зелёный НТР + аккуратные акценты
   ================================================================ */

:root {
    --bg:        #0f1419;
    --bg-elev:   #1a2027;
    --bg-elev2:  #232c37;
    --border:    #2a3340;
    --text:      #e6e8eb;
    --text-dim:  #8b95a1;
    --text-mute: #6b7480;
    --success:   #22c55e;
    --success-d: #16a34a;
    --info:      #60a5fa;
    --accent:    #34d399;
    --warn:      #f59e0b;
    --danger:    #ef4444;
    --shadow:    0 4px 12px rgba(0,0,0,0.25);
    --radius:    12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.link-strong { color: var(--text); font-weight: 500; }
.link-strong:hover { color: var(--success); text-decoration: none; }

.muted { color: var(--text-dim); }
.small { font-size: 12px; }
.mono { font-family: SFMono-Regular, Consolas, Menlo, monospace; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.m-0 { margin: 0; }
.mt-1 { margin-top: 8px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.max-700 { max-width: 700px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }

/* ---------- Расчёт себестоимости проекта ---------- */
.cost-total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: var(--bg-elev2);
    border: 1px solid var(--border);
    font-size: 15px;
}
.cost-total-bar strong { font-size: 20px; color: var(--success); white-space: nowrap; }
.cost-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
    background: #0c1115;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; justify-content: center; padding: 16px 10px; border-bottom: 1px solid var(--border); }
.brand-img { width: 100%; max-width: 230px; height: auto; display: block; object-fit: contain; }
.nav { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    color: var(--text-dim); text-decoration: none; font-size: 13px; font-weight: 500;
}
.nav-item:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.nav-icon { width: 18px; text-align: center; opacity: 0.9; font-size: 14px; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--success); color: var(--bg);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-dim); }
.logout-btn { color: var(--text-dim); padding: 6px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
.logout-btn svg { display: block; }
.logout-btn:hover { color: var(--danger); background: var(--bg-elev); text-decoration: none; }

.main { padding: 0; max-width: 100%; overflow-x: auto; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--bg);
    position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.ai-badge { padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.ai-badge.on { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.ai-badge.off { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.content { padding: 24px 28px; }

/* ---------- Flash ---------- */
.flash { margin: 16px 28px 0 28px; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; }
.flash-success { background: rgba(34, 197, 94, 0.15); color: var(--success); border: 1px solid var(--success); }
.flash-error   { background: rgba(239, 68, 68, 0.15); color: var(--danger);  border: 1px solid var(--danger); }

/* ---------- Grid & cards ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
    .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; margin: 0 0 12px 0; font-weight: 600; }
.card h3 { font-size: 14px; margin: 0 0 8px 0; font-weight: 600; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-header h2 { margin: 0; }
.card-link { font-size: 12px; color: var(--success); }

.empty { padding: 32px; text-align: center; color: var(--text-dim); }

/* ---------- KPI ---------- */
.kpi {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--text); }
.kpi-value.sm { font-size: 20px; }
.kpi-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.kpi-sub { font-size: 11px; color: var(--text-mute); margin-top: 6px; }
.kpi-success .kpi-value { color: var(--success); }
.kpi-info .kpi-value { color: var(--info); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 11px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table.table-sm th, .table.table-sm td { padding: 6px 8px; }
.table tr.edit-row > td { background: var(--bg-elev); box-shadow: inset 3px 0 0 var(--accent); }
.table tr.edit-row:hover > td { background: var(--bg-elev); }
.table tr.edit-row .form { margin: 4px 0; }

/* ---------- Buttons & forms ---------- */
.btn {
    display: inline-block; padding: 8px 14px;
    background: var(--bg-elev2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px; font-family: inherit; text-decoration: none;
    transition: all 0.15s ease;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: var(--success); color: var(--bg); border-color: var(--success); font-weight: 600; }
.btn-primary:hover { background: var(--success-d); border-color: var(--success-d); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; font-weight: 500; }
.field small { display: block; font-size: 11px; color: var(--text-mute); margin-top: 4px; }
.field input, .field select, .field textarea {
    display: block; width: 100%;
    padding: 9px 12px; font-size: 14px; font-family: inherit;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.form-error { padding: 10px 14px; background: rgba(239,68,68,0.15); color: var(--danger); border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; }
.form-hint { color: var(--text-dim); font-size: 13px; }
.inline-form { display: inline-block; }
.inline-form select { display: inline-block; width: auto; padding: 4px 8px; font-size: 12px; }

/* ---------- Page actions ---------- */
.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-actions h1 { font-size: 20px; line-height: 1.3; margin: 0; }
.page-actions .actions { display: flex; gap: 8px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.filter-bar input, .filter-bar select { padding: 8px 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 13px; }
.filter-bar input[type=search] { flex: 1; min-width: 200px; }

/* ---------- Автопоиск закупок: автоподбор по профилю + компактные действия ---------- */
.autofill-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.btn-autofill {
    background: linear-gradient(135deg, #38bdf8 0%, #6366f1 52%, #a855f7 100%);
    color: #fff; border: none; font-weight: 600;
}
.btn-autofill:hover { filter: brightness(1.08); background: linear-gradient(135deg, #38bdf8 0%, #6366f1 52%, #a855f7 100%); }
.btn-autofill:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.4); }
/* Действия в таблице результатов — компактные кнопки, переносятся вместо распирания строки */
.ts-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-start; }
.ts-actions .btn-sm { padding: 3px 8px; }
/* Кратковременная подсветка полей, заполненных автоподбором */
.field-autofilled { border-color: #6366f1 !important; box-shadow: 0 0 0 3px rgba(99,102,241,0.18) !important; transition: box-shadow .3s ease, border-color .3s ease; }

/* ---------- Поиск в интернете: заголовок находки, фрагмент, сигналы ---------- */
.web-title { font-weight: 600; color: var(--info); text-decoration: none; line-height: 1.35; }
.web-title:hover { text-decoration: underline; }
.web-snippet { margin-top: 4px; color: var(--text-mute); font-size: 12px; line-height: 1.45; }
.web-signals { display: flex; flex-wrap: wrap; gap: 4px; }
.web-signals .tag {
    display: inline-block; padding: 1px 7px; border-radius: 999px;
    background: var(--bg-elev2); border: 1px solid var(--border);
    color: var(--text-dim); font-size: 11px; white-space: nowrap;
}

/* ---------- «Нейроанализ»: оверлей обработки веб-поиска ---------- */
.neuro-overlay {
    position: fixed; inset: 0; z-index: 10000; display: none;
    align-items: end; justify-items: center;
    background: radial-gradient(circle at 50% 38%, rgba(20,26,38,0.82), rgba(7,10,17,0.96));
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.neuro-overlay.is-active { display: grid; }
.neuro-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.neuro-hud {
    position: relative; z-index: 2; text-align: center; pointer-events: none;
    width: min(560px, 92vw); padding: 0 20px; margin-bottom: clamp(24px, 8vh, 96px);
}
.neuro-title {
    display: inline-flex; align-items: center; gap: 10px;
    font-size: clamp(18px, 2.4vw, 24px); font-weight: 700; letter-spacing: .3px;
    color: #eaf2ff; text-shadow: 0 0 20px rgba(99,102,241,0.55);
}
.neuro-orb {
    width: 16px; height: 16px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #7dd3fc, #6366f1 55%, #a855f7);
    box-shadow: 0 0 14px rgba(125,211,252,0.9), 0 0 26px rgba(168,85,247,0.55);
    animation: neuroPulse 1.15s ease-in-out infinite;
}
.neuro-dots { display: inline-block; width: 1.2em; text-align: left; }
.neuro-phase { margin-top: 12px; min-height: 20px; color: #9fb3d1; font-size: 14px; }
.neuro-pct {
    margin-top: 12px; font-weight: 800; line-height: 1; color: #fff;
    font-size: clamp(40px, 7vw, 60px); font-variant-numeric: tabular-nums;
    text-shadow: 0 0 26px rgba(56,189,248,0.5);
}
.neuro-bar {
    margin: 16px auto 0; width: min(340px, 84%); height: 10px; overflow: hidden;
    border-radius: 999px; background: rgba(255,255,255,0.08);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.neuro-bar-fill {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, #38bdf8, #6366f1 55%, #a855f7);
    box-shadow: 0 0 16px rgba(99,102,241,0.7); transition: width .18s ease-out;
}
.neuro-stat { margin-top: 12px; color: #7f8ba0; font-size: 12px; letter-spacing: .4px; }
.neuro-skip {
    margin-top: 16px; pointer-events: auto; cursor: pointer;
    background: rgba(255,255,255,0.06); color: #9fb3d1;
    border: 1px solid rgba(255,255,255,0.14); border-radius: 8px;
    padding: 6px 14px; font-size: 12px;
}
.neuro-skip:hover { background: rgba(255,255,255,0.12); color: #eaf2ff; }
@keyframes neuroPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.28); opacity: .72; } }
@media (prefers-reduced-motion: reduce) {
    .neuro-orb { animation: none; }
}

/* ---------- Status & decision ---------- */
.status, .badge {
    display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 11px; font-weight: 600;
    background: var(--bg-elev2); color: var(--text-dim);
}
.status-imported  { background: rgba(96, 165, 250, 0.15); color: var(--info); }
.status-parsing   { background: rgba(245, 158, 11, 0.15); color: var(--warn); }
.status-analyzing { background: rgba(245, 158, 11, 0.15); color: var(--warn); }
.status-analyzed  { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.status-decided   { background: rgba(34, 197, 94, 0.25); color: var(--success); }
.status-closed    { background: var(--bg-elev2); color: var(--text-mute); }

.decision-go      { color: var(--success); font-weight: 600; }
.decision-cond    { color: var(--warn); font-weight: 600; }
.decision-no      { color: var(--danger); font-weight: 600; }
.decision-pending { color: var(--text-dim); }

.days-urgent { color: var(--danger); font-weight: 600; }
.days-warn   { color: var(--warn); font-weight: 500; }

.badge-risk   { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-tailor { background: rgba(245,158,11,0.15); color: var(--warn); }

/* ---------- Журнал: уровни логов ---------- */
.badge-log-debug    { background: var(--bg-elev2); color: var(--text-mute); }
.badge-log-info     { background: rgba(96,165,250,0.15); color: var(--info); }
.badge-log-notice   { background: rgba(96,165,250,0.10); color: var(--text-dim); }
.badge-log-warning  { background: rgba(245,158,11,0.15); color: var(--warn); }
.badge-log-error    { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-log-critical { background: var(--danger); color: #fff; }

/* ---------- Scores ---------- */
.score-bar { position: relative; height: 18px; background: var(--bg); border-radius: 4px; overflow: hidden; min-width: 80px; }
.score-bar > div { height: 100%; background: var(--success); }
.score-bar > span { position: absolute; left: 0; right: 0; top: 0; bottom: 0; text-align: center; font-size: 11px; line-height: 18px; color: var(--text); font-weight: 600; }

.score-bar-mini { height: 4px; background: var(--bg); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.score-bar-mini > div { height: 100%; }

.scores-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px; margin-top: 12px;
}
.score-tile {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.score-tile-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.score-tile-value { font-size: 18px; font-weight: 700; margin-top: 2px; }
.score-unit { font-size: 12px; color: var(--text-dim); margin-left: 2px; }
.score-tile-desc { font-size: 10px; color: var(--text-mute); margin-top: 6px; }

.impact { font-weight: 600; font-family: monospace; }
.impact.pos { color: var(--success); }
.impact.neg { color: var(--danger); }
.impact-bar { height: 6px; background: var(--bg); border-radius: 3px; position: relative; overflow: hidden; min-width: 80px; }
.impact-fill { height: 100%; }
.impact-fill.pos { background: var(--success); }
.impact-fill.neg { background: var(--danger); }

/* ---------- Risk/Rec lists ---------- */
.risk-list { list-style: none; padding: 0; margin: 0; }
.risk-item { padding: 10px 12px; border-left: 3px solid var(--border); margin-bottom: 8px; background: var(--bg); border-radius: 0 4px 4px 0; }
.risk-item.severity-critical { border-left-color: var(--danger); }
.risk-item.severity-high     { border-left-color: var(--danger); opacity: 0.9; }
.risk-item.severity-medium   { border-left-color: var(--warn); }
.risk-item.severity-low      { border-left-color: var(--info); }

.risk-badge {
    display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 10px; font-weight: 700; margin-right: 8px; text-transform: uppercase;
}
.sev-critical { background: var(--danger); color: white; }
.sev-high     { background: rgba(239,68,68,0.7); color: white; }
.sev-medium   { background: var(--warn); color: var(--bg); }
.sev-low      { background: var(--info); color: var(--bg); }

.rec-list { list-style: none; padding: 0; margin: 0; }
.rec-item { display: flex; gap: 12px; padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 6px; }
.rec-priority {
    width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
    background: var(--accent); color: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px;
}
.rec-body { flex: 1; }

.match { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 8px; }
.match-met     { background: rgba(34,197,94,0.15); color: var(--success); }
.match-partial { background: rgba(96,165,250,0.15); color: var(--info); }
.match-partner { background: rgba(245,158,11,0.15); color: var(--warn); }
.match-not_met { background: rgba(239,68,68,0.15); color: var(--danger); }
.match-unknown { background: var(--bg-elev2); color: var(--text-dim); }

.crit-critical    { background: rgba(239,68,68,0.15); color: var(--danger); }
.crit-significant { background: rgba(245,158,11,0.15); color: var(--warn); }
.crit-additional  { background: rgba(96,165,250,0.15); color: var(--info); }
.crit-desired     { background: var(--bg-elev2); color: var(--text-dim); }

/* ---------- Documents ---------- */
.upload-form { display: none; padding: 16px; background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 12px; }
.upload-form.show { display: block; }

.doc-text {
    max-height: 600px;
    overflow: auto;
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    font-family: SFMono-Regular, Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 13px; margin: 0; }
.dl.two-col { grid-template-columns: 180px 1fr; }
.dl dt { color: var(--text-dim); font-size: 12px; }
.dl dd { margin: 0; }

/* ---------- Tabs ---------- */
.tabs {
    display: flex; gap: 4px; border-bottom: 1px solid var(--border);
    margin: -4px 0 16px 0;
}
.tab {
    padding: 10px 16px; color: var(--text-dim); text-decoration: none;
    border-bottom: 2px solid transparent; font-size: 13px; font-weight: 500;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--success); border-bottom-color: var(--success); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---------- Cite list ---------- */
.cite-list { padding-left: 16px; }
.cite-list li { margin-bottom: 8px; font-size: 12px; }
.cite-doc { color: var(--text-dim); }

/* ---------- Auth page ---------- */
.auth-body {
    background: linear-gradient(135deg, #0f1419 0%, #1a2027 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.starry-bg {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    z-index: 0; display: block;
    pointer-events: none;
}
.auth-shell {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: 1.2fr 1fr;
    max-width: 960px; width: 100%;
    background: rgba(20, 26, 31, 0.92);
    backdrop-filter: blur(6px);
    border-radius: 16px;
    overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    border: 1px solid var(--border);
}
@media (max-width: 720px) { .auth-shell { grid-template-columns: 1fr; } }
.auth-side {
    padding: 40px;
    background: linear-gradient(135deg, rgba(20,33,23,0.85) 0%, rgba(15,20,25,0.85) 100%);
    border-right: 1px solid var(--border);
}
.auth-logo {
    width: 148px; margin-bottom: 24px;
    filter: drop-shadow(0 6px 20px rgba(34,197,94,0.35));
}
.auth-side h1 { color: var(--success); font-size: 28px; margin: 0 0 12px 0; }
.auth-side p { color: var(--text-dim); }
.auth-features { list-style: none; padding: 0; margin-top: 24px; }
.auth-features li { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--text-dim); font-size: 13px; }
.auth-features li span { color: var(--success); font-size: 16px; width: 22px; }

.auth-form-wrap { padding: 40px; display: flex; align-items: center; }
.auth-form { width: 100%; }
.auth-form h2 { margin: 0; }

/* ---------- Reports ---------- */
.report-page { max-width: 900px; margin: 0 auto; }
.report-header { display: flex; align-items: center; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.report-logo { width: 56px; height: 56px; }
.report-header h1 { margin: 0; }
.report-actions { margin-left: auto; display: flex; gap: 8px; }
.report-section { margin-bottom: 28px; }
.report-section h2 { color: var(--success); border-bottom: 1px solid var(--border); padding-bottom: 8px; font-size: 18px; }
.big-decision {
    padding: 20px; font-size: 32px; font-weight: 800; text-align: center;
    background: var(--bg); border-radius: var(--radius); margin: 12px 0;
}
.risk-list-report { padding-left: 24px; }
.risk-list-report li { margin-bottom: 12px; }
.report-footer { text-align: center; padding-top: 24px; border-top: 1px solid var(--border); color: var(--text-mute); font-size: 12px; }

/* ---------- Charts (inline SVG) ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart-donut { max-width: 220px; margin: 0 auto; }
.chart-empty { padding: 28px; text-align: center; color: var(--text-dim); font-size: 13px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: 12px; color: var(--text-dim); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.legend-item strong { color: var(--text); font-weight: 600; }

/* ---------- Topbar search ---------- */
.topbar-search input[type=search] {
    width: 240px; max-width: 38vw;
    padding: 7px 12px; font-size: 13px; font-family: inherit;
    background: var(--bg-elev); color: var(--text);
    border: 1px solid var(--border); border-radius: 999px;
}
.topbar-search input[type=search]:focus {
    outline: none; border-color: var(--success); width: 300px;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

/* ---------- Price optimizer ---------- */
.opt-layout { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.opt-controls { position: sticky; top: 92px; }
.opt-controls h2 { font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.opt-slider span { display: flex; justify-content: space-between; align-items: baseline; }
.opt-val { color: var(--success); font-weight: 700; font-variant-numeric: tabular-nums; }
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px;
    background: var(--bg); accent-color: var(--success); outline: none; margin: 6px 0; }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: var(--success); cursor: pointer; border: 2px solid var(--bg-elev); }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--success);
    cursor: pointer; border: 2px solid var(--bg-elev); }
.range-inverse { accent-color: var(--warn); }
.range-inverse::-webkit-slider-thumb { background: var(--warn); }
.range-inverse::-moz-range-thumb { background: var(--warn); }
.opt-results { min-width: 0; }
.row-rec { background: rgba(34, 197, 94, 0.10) !important; }
.row-rec td { font-weight: 600; }
@media (max-width: 1100px) { .opt-layout { grid-template-columns: 1fr; } .opt-controls { position: static; } }

/* ---------- Analytics ---------- */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: 150px 1fr 60px; align-items: center; gap: 10px; font-size: 13px; }
.funnel-bar { height: 22px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.funnel-bar > div { height: 100%; background: linear-gradient(90deg, var(--success-d), var(--success)); min-width: 2px; }
.funnel-row .funnel-n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Global search ---------- */
.search-group { margin-bottom: 24px; }
.search-group h2 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.search-item { display: block; padding: 12px 14px; background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: var(--radius-sm); margin-bottom: 8px; color: var(--text); }
.search-item:hover { border-color: var(--success); text-decoration: none; background: var(--bg-elev2); }
.search-item .si-title { font-weight: 600; color: var(--text); }
.search-item .si-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.search-hit { background: rgba(34, 197, 94, 0.22); color: var(--text); border-radius: 3px; padding: 0 2px; }

/* ---------- Compliance traffic light (#9) ---------- */
.compliance { border-left: 4px solid var(--border); }
.compliance-green  { border-left-color: var(--success); }
.compliance-yellow { border-left-color: var(--warn); }
.compliance-red    { border-left-color: var(--danger); }
.compliance-head { display: flex; align-items: center; gap: 18px; }
.compliance-verdict { min-width: 0; }
.compliance-title { font-size: 18px; font-weight: 700; }
.compliance-green  .compliance-title { color: var(--success); }
.compliance-yellow .compliance-title { color: var(--warn); }
.compliance-red    .compliance-title { color: var(--danger); }
.traffic-light { display: inline-flex; flex-direction: column; gap: 6px; padding: 8px;
    background: var(--bg); border-radius: 10px; border: 1px solid var(--border); }
.tl-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-elev2); opacity: 0.25; }
.traffic-red    .tl-red    { background: var(--danger);  opacity: 1; box-shadow: 0 0 8px var(--danger); }
.traffic-yellow .tl-yellow { background: var(--warn);    opacity: 1; box-shadow: 0 0 8px var(--warn); }
.traffic-green  .tl-green  { background: var(--success); opacity: 1; box-shadow: 0 0 8px var(--success); }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
    background: var(--bg); border-radius: var(--radius-sm); border-left: 3px solid var(--border); }
.check-item.check-met     { border-left-color: var(--success); }
.check-item.check-partial { border-left-color: var(--warn); }
.check-item.check-missing { border-left-color: var(--danger); }
.check-icon { font-size: 15px; line-height: 1.4; flex: 0 0 auto; }
.check-met     .check-icon { color: var(--success); }
.check-partial .check-icon { color: var(--warn); }
.check-missing .check-icon { color: var(--danger); }
.check-body { min-width: 0; }
.compliance-missing { padding: 12px 14px; background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.25); border-radius: var(--radius-sm); }
.missing-list { margin: 6px 0 0 0; padding-left: 20px; font-size: 13px; color: var(--text); }
.missing-list li { margin-bottom: 4px; }

/* ---------- Tender radar (#2) ---------- */
@keyframes radar-pulse-green {
    0%, 100% { background: rgba(34,197,94,0.07); box-shadow: inset 3px 0 0 var(--success); }
    50%      { background: rgba(34,197,94,0.20); box-shadow: inset 3px 0 0 var(--success), 0 0 10px rgba(34,197,94,0.25); }
}
@keyframes radar-pulse-amber {
    0%, 100% { background: rgba(245,158,11,0.06); box-shadow: inset 3px 0 0 var(--warn); }
    50%      { background: rgba(245,158,11,0.16); box-shadow: inset 3px 0 0 var(--warn), 0 0 10px rgba(245,158,11,0.22); }
}
.radar-on tr.row-radar { animation: radar-pulse-green 1.7s ease-in-out infinite; }
.radar-on tr.row-radar.radar-close { animation: radar-pulse-amber 1.7s ease-in-out infinite; }
.btn-radar.active { background: var(--success); color: var(--bg); border-color: var(--success); font-weight: 600; }
.radar-badge { display: none; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 10px;
    font-size: 11px; font-weight: 600; background: rgba(34,197,94,0.15); color: var(--success); white-space: nowrap; margin-top: 4px; }
.radar-badge.lvl-yellow { background: rgba(245,158,11,0.15); color: var(--warn); }
.radar-on .radar-badge { display: inline-flex; }

/* ---------- Вердикт пригодности автоподбора конкурсов ---------- */
.fit-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
    border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.fit-badge.fit-green  { background: rgba(34,197,94,0.15);  color: var(--success); }
.fit-badge.fit-yellow { background: rgba(245,158,11,0.15); color: var(--warn); }
.fit-badge.fit-red    { background: rgba(239,68,68,0.15);  color: var(--danger); }
.fit-badge.fit-none   { background: var(--bg-elev); color: var(--text-mute); }

/* ---------- Tailoring / fairness (#3) ---------- */
.text-warn { color: var(--warn); }
.text-muted { color: var(--text-mute); }
.fairness { border-left: 4px solid var(--border); }
.fairness-fair       { border-left-color: var(--success); }
.fairness-suspicious { border-left-color: var(--warn); }
.fairness-tailored   { border-left-color: var(--danger); }
.fairness-head { display: flex; align-items: center; gap: 18px; }
.fairness-gauge { flex: 0 0 auto; width: 76px; height: 76px; border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 4px solid var(--border); background: var(--bg); }
.fairness-gauge.gauge-success { border-color: var(--success); }
.fairness-gauge.gauge-warn    { border-color: var(--warn); }
.fairness-gauge.gauge-danger  { border-color: var(--danger); }
.fairness-gauge.gauge-muted   { border-color: var(--border); }
.fairness-num { font-size: 24px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.fairness-of { font-size: 11px; color: var(--text-mute); }
.fairness-verdict { min-width: 0; }
.fairness-title { font-size: 18px; font-weight: 700; }
.signal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.signal-item { padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm); border-left: 3px solid var(--border); }
.signal-item.sev-high   { border-left-color: var(--danger); }
.signal-item.sev-medium { border-left-color: var(--warn); }
.signal-item.sev-low    { border-left-color: var(--info); }
.signal-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.signal-badge { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.3px; }
.sigsev-high   { background: rgba(239,68,68,0.15); color: var(--danger); }
.sigsev-medium { background: rgba(245,158,11,0.15); color: var(--warn); }
.sigsev-low    { background: rgba(96,165,250,0.15); color: var(--info); }
.signal-ex { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.signal-ex code { background: var(--bg-elev2); color: var(--text-dim); padding: 2px 7px; border-radius: 4px; font-size: 12px; }

/* ---------- Цифровой двойник заказчика ---------- */
.twin-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.twin-arch { font-size: 13px; font-weight: 700; padding: 4px 12px; }
.twin-arch-price_hunter   { background: rgba(96,165,250,0.15); color: var(--info); }
.twin-arch-captive        { background: rgba(239,68,68,0.15); color: var(--danger); }
.twin-arch-quality_seeker { background: rgba(34,197,94,0.15); color: var(--success); }
.twin-arch-balanced       { background: rgba(245,158,11,0.15); color: var(--warn); }
.twin-arch-low_data       { background: var(--bg-elev2); color: var(--text-mute); }
.twin-big { font-size: 28px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.twin-strategy { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.twin-strategy li { color: var(--text-dim); font-size: 14px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: 999px;
    background: var(--bg-elev2); border: 1px solid var(--border);
    color: var(--text-dim); font-size: 13px; text-decoration: none;
    transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); background: var(--bg-elev); }
.chip .muted { font-size: 12px; }

/* ---------- Сторож изменений (#7) ---------- */
.watch-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.watch-feed li { display: flex; align-items: baseline; gap: 8px; font-size: 14px; color: var(--text-dim); }
.nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto;
    border-radius: 9px; background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 700; line-height: 1;
}

/* ---------- Сборка заявки (#6) ---------- */
.bid-section { padding: 14px 0; border-top: 1px solid var(--border); }
.bid-section:first-child { border-top: 0; padding-top: 4px; }
.bid-section-title { margin: 0 0 6px; font-size: 15px; }
.bid-section-body { margin: 0 0 8px; }
.bid-list { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.bid-list li { font-size: 14px; color: var(--text); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-elev2); }

/* ================================================================
   Эврика 2.0 — встроенный ИИ-ассистент (переливающийся шар)
   ================================================================ */
.eureka {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
}

/* --- Шар-кнопка --- */
.eureka-orb {
    position: relative;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: linear-gradient(135deg, #38bdf8 0%, #6366f1 52%, #a855f7 100%);
    background-size: 200% 200%;
    box-shadow: 0 8px 26px rgba(99, 102, 241, 0.45), inset 0 0 14px rgba(255, 255, 255, 0.15);
    animation: eurekaShimmer 7s ease-in-out infinite;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}
.eureka-orb:hover { transform: scale(1.06); }
.eureka-orb:focus-visible { box-shadow: 0 8px 26px rgba(99, 102, 241, 0.55), 0 0 0 3px rgba(168, 85, 247, 0.45); }
/* Глянцевый блик + мягкое свечение */
.eureka-orb-core {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 42%),
        radial-gradient(circle at 70% 80%, rgba(168, 85, 247, 0.55), rgba(168, 85, 247, 0) 55%);
    pointer-events: none;
}
.eureka-orb-glow {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.45), rgba(168, 85, 247, 0) 70%);
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
/* Состояние «думает» — мягкий перелив голубой→фиолетовый + дыхание */
.eureka.is-thinking .eureka-orb {
    animation: eurekaShimmer 2.2s ease-in-out infinite,
               eurekaGlow 2.2s ease-in-out infinite,
               eurekaBreath 2.2s ease-in-out infinite;
}
.eureka.is-thinking .eureka-orb-glow { opacity: 1; }

@keyframes eurekaShimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes eurekaGlow {
    0%, 100% { box-shadow: 0 8px 26px rgba(56, 189, 248, 0.5), inset 0 0 14px rgba(255, 255, 255, 0.15); }
    50%      { box-shadow: 0 8px 34px rgba(168, 85, 247, 0.75), 0 0 26px rgba(168, 85, 247, 0.5), inset 0 0 16px rgba(255, 255, 255, 0.25); }
}
@keyframes eurekaBreath {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

/* --- Панель диалога --- */
.eureka-panel {
    width: 370px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: eurekaPanelIn 0.22s ease;
}
.eureka[data-open="1"] .eureka-panel { display: flex; }
@keyframes eurekaPanelIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.eureka-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(168, 85, 247, 0.14));
}
.eureka-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.eureka-title-orb {
    width: 16px; height: 16px; border-radius: 50%;
    background: linear-gradient(135deg, #38bdf8, #a855f7);
    background-size: 200% 200%;
    animation: eurekaShimmer 7s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}
.eureka-close {
    border: none; background: transparent; color: var(--text-dim);
    font-size: 16px; line-height: 1; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.eureka-close:hover { background: var(--bg-elev2); color: var(--text); }

.eureka-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.eureka-msg { max-width: 86%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.eureka-msg-user { align-self: flex-end; background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; border-bottom-right-radius: 4px; }
.eureka-msg-bot { align-self: flex-start; background: var(--bg-elev2); color: var(--text); border-bottom-left-radius: 4px; }
.eureka-msg-bot a { color: var(--info); }
.eureka-msg-error { align-self: flex-start; background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); border-radius: 10px; }
.eureka-hello { color: var(--text-dim); font-size: 13px; line-height: 1.55; }
.eureka-hello b { color: var(--text); }
.eureka-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.eureka-chip {
    border: 1px solid var(--border); background: var(--bg); color: var(--text-dim);
    font-size: 12px; padding: 5px 10px; border-radius: 14px; cursor: pointer; transition: all 0.15s ease;
}
.eureka-chip:hover { color: var(--text); border-color: #6366f1; }
/* Индикатор набора ответа */
.eureka-typing { display: inline-flex; gap: 4px; align-items: center; }
.eureka-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); animation: eurekaDot 1.2s infinite ease-in-out; }
.eureka-typing span:nth-child(2) { animation-delay: 0.2s; }
.eureka-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes eurekaDot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.eureka-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--bg); }
.eureka-input {
    flex: 1; resize: none; max-height: 120px;
    background: var(--bg-elev); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 9px 11px; font: inherit; font-size: 13.5px; line-height: 1.4;
}
.eureka-input:focus { outline: none; border-color: #6366f1; }
.eureka-send {
    align-self: flex-end;
    width: 40px; height: 40px; flex: 0 0 40px;
    border: none; border-radius: var(--radius-sm); cursor: pointer;
    background: linear-gradient(135deg, #38bdf8, #a855f7); color: #fff; font-size: 15px;
    transition: opacity 0.2s ease, transform 0.15s ease;
}
.eureka-send:hover:not(:disabled) { transform: translateY(-1px); }
.eureka-send:disabled { opacity: 0.45; cursor: default; }

@media (max-width: 640px) {
    .eureka { right: 14px; bottom: 14px; }
    .eureka-panel { height: 62vh; }
}
