/* ========================================
   Каркас — Стили платформы
   ======================================== */

/* --- Переменные --- */
:root {
    --bg: #f5f5f5;
    --card: #ffffff;
    --text: #1a1a1a;
    --text-sec: #666666;
    --text-muted: #999999;
    --border: #e0e0e0;
    --accent: #1a73e8;
    --accent-bg: #e8f0fe;
    --blue: #1a73e8;
    --blue-bg: #e8f0fe;
    --green: #1e8e3e;
    --green-bg: #e6f4ea;
    --red: #d32f2f;
    --red-bg: #fce8e6;
    --orange: #f9ab00;
    --orange-bg: #fef7e0;
    --header-h: 60px;
    --radius: 8px;
}

/* --- Сброс --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

/* --- Шапка --- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.header-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--blue);
    color: white;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 20px;
}

.header-logo-text {
    font-weight: 700;
    font-size: 18px;
}

.header-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg);
}

.header-search input:focus {
    outline: none;
    border-color: var(--blue);
    background: var(--card);
}

.header-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.header-spacer {
    flex: 1;
}

.header-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sec);
}

.header-btn:hover {
    background: var(--bg);
    color: var(--text);
}

/* --- Боковое меню --- */
.sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 280px;
    background: var(--card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px;
}

.sidebar-item {
    display: block;
    padding: 10px 12px;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
}

.sidebar-item:hover {
    background: var(--bg);
}

.sidebar-item.active {
    background: var(--blue-bg);
    color: var(--blue);
    font-weight: 500;
}

.sidebar-item-num {
    color: var(--text-muted);
    margin-right: 8px;
    font-size: 13px;
}

/* --- Основной контент --- */
.main {
    margin-left: 280px;
    margin-top: var(--header-h);
    padding: 24px;
    min-height: calc(100vh - var(--header-h));
}

.content {
    max-width: 900px;
}

/* --- Карточки --- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* --- Заголовки разделов --- */
.section-header {
    margin-bottom: 24px;
}

.section-num {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.section-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.section-desc {
    color: var(--text-sec);
}

/* --- Калькулятор --- */
.calc-panel {
    background: linear-gradient(135deg, var(--blue-bg) 0%, var(--card) 100%);
    border: 2px solid var(--blue);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.calc-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--blue);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.calc-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calc-field label {
    font-size: 12px;
    color: var(--text-sec);
    min-height: 32px;
    display: flex;
    align-items: flex-end;
    line-height: 1.3;
}

.calc-field .unit {
    font-size: 10px;
    color: var(--text-muted);
}

.calc-field input,
.calc-field select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: 'SF Mono', 'Consolas', monospace;
    background: var(--card);
}

.calc-field input:focus,
.calc-field select:focus {
    outline: none;
    border-color: var(--blue);
}

.calc-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.calc-result {
    background: var(--card);
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
}

.calc-result .label {
    font-size: 10px;
    color: var(--text-muted);
}

.calc-result .value {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-weight: 600;
}

/* --- Формулы --- */
.formula {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 16px 0;
}

.formula.ok {
    border-color: var(--green);
    background: linear-gradient(135deg, var(--green-bg) 0%, var(--card) 100%);
}

.formula.fail {
    border-color: var(--red);
    background: linear-gradient(135deg, var(--red-bg) 0%, var(--card) 100%);
}

.formula-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.formula-num {
    background: var(--blue);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.formula-name {
    font-weight: 600;
    font-size: 14px;
}

.formula-badge {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.formula-badge.ok {
    background: var(--green);
    color: white;
}

.formula-badge.fail {
    background: var(--red);
    color: white;
}

.formula-row {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 14px;
    margin: 8px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.formula-symbolic {
    background: var(--bg);
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--text-sec);
}

.formula-result {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
}

.formula-usage {
    font-size: 12px;
    color: var(--text-sec);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

/* --- Текст СП --- */
.sp-text {
    margin: 16px 0;
    line-height: 1.7;
}

.sp-text p {
    margin-bottom: 12px;
}

/* --- Аккордеон --- */
.accordion {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px 0;
    overflow: hidden;
}

.accordion-header {
    padding: 12px 16px;
    background: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 14px;
}

.accordion-header:hover {
    background: var(--border);
}

.accordion-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.2s;
}

.accordion.open .accordion-icon {
    transform: rotate(180deg);
}

.accordion-body {
    padding: 16px;
    display: none;
    background: var(--card);
}

.accordion.open .accordion-body {
    display: block;
}

/* --- Заметки --- */
.note {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin: 12px 0;
    font-size: 13px;
}

.note.info {
    background: var(--blue-bg);
    border-left: 4px solid var(--blue);
}

.note.warn {
    background: var(--orange-bg);
    border-left: 4px solid var(--orange);
}

.note.success {
    background: var(--green-bg);
    border-left: 4px solid var(--green);
}

/* --- Таблицы --- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 12px 0;
}

th, td {
    border: 1px solid var(--border);
    padding: 10px 12px;
    text-align: left;
}

th {
    background: var(--bg);
    font-weight: 600;
}

tr:hover {
    background: var(--bg);
}

tr.active {
    background: var(--blue-bg);
}

/* --- Списки --- */
.tips {
    list-style: none;
    padding: 0;
}

.tips li {
    padding: 6px 0 6px 20px;
    position: relative;
}

.tips li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--blue);
    font-weight: bold;
}

/* --- Адаптив --- */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .main {
        margin-left: 0;
    }
    
    .calc-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- Поиск --- */
.header-search {
    position: relative;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 4px;
}

.search-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: var(--bg-hover);
}

.search-item-title {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.search-item-match {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.search-item-match mark {
    background: var(--yellow-bg);
    color: var(--text);
    padding: 0 2px;
    border-radius: 2px;
}

.search-no-results {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
}

.search-more {
    padding: 12px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--bg-hover);
}

/* --- Табы подразделов (исправление) --- */
.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    padding: 4px;
    background: var(--bg-hover);
    border-radius: 12px;
}

.nav-tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-tab:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-tab.active {
    background: var(--bg);
    color: var(--blue);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- Статьи (подразделы) --- */
.article {
    display: none;
}

.article.active {
    display: block;
}

/* --- Карточки терминов --- */
.term-card {
    background: var(--bg-hover);
    border-left: 4px solid var(--blue);
    padding: 16px 20px;
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
}

.term-card h4 {
    margin: 0 0 8px 0;
    color: var(--blue);
    font-size: 16px;
}

.term-card p {
    margin: 0;
    color: var(--text);
}
