/* Общие стили приложения ПГПТ. Подключается после Bootstrap на всех страницах. */

:root {
    --brand: #076db4;
    --brand-hover: #055a95;
    --brand-soft: #e8f2fa;
    --bg: #f3f6f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --danger: #c0352b;
    --danger-soft: #fdecea;
    --success: #13795b;
    --success-soft: #e6f4ee;
    --warning: #a15c07;
    --warning-soft: #fdf3e2;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    min-height: 100vh;
}

a { color: var(--brand); }
a:hover { color: var(--brand-hover); }

/* ---------- Кнопки ---------- */
.btn { border-radius: 8px; font-weight: 500; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-light { background: #fff; border-color: var(--border); }
.btn-light:hover { background: var(--brand-soft); border-color: var(--border); }

.form-control, .form-select { border-radius: 8px; border-color: #cfd8e3; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(7, 109, 180, .15); }
.form-label { font-weight: 500; color: #334155; margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* ---------- Шапка ---------- */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1020;
}
.app-header__inner {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 68px;
    flex-wrap: wrap;
}
.app-header__logo img { height: 54px; width: auto; display: block; margin: -4px 0; }
.app-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.app-nav a {
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.app-nav a:hover { background: var(--bg); color: var(--text); }
.app-nav a.active { background: var(--brand-soft); color: var(--brand); }
.app-user { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.app-user__name { text-align: right; line-height: 1.25; }
.app-user__name strong { display: block; font-weight: 600; }
.app-user__name span { color: var(--muted); font-size: 13px; }

@media (max-width: 991.98px) {
    .app-header__inner { gap: 8px 16px; padding-top: 8px; padding-bottom: 8px; }
    .app-nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
}
@media (max-width: 575.98px) {
    .app-user__name { display: none; }
}

/* ---------- Контент ---------- */
.app-main { padding-top: 24px; padding-bottom: 48px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-title { font-size: 24px; font-weight: 600; margin: 0; }
.page-subtitle { color: var(--muted); margin: 2px 0 0; }
.back-link { color: var(--muted); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 6px; }
.back-link:hover { color: var(--brand); }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.panel + .panel { margin-top: 20px; }
.panel-title {
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.panel-title small { font-size: 13px; color: var(--muted); font-weight: 400; }

/* Список «ключ — значение» */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 400; }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

/* Аватар врача */
.avatar {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--brand-soft);
    display: block;
    margin: 0 auto 14px;
}

/* Поиск */
.search-input {
    max-width: 320px;
    padding-left: 36px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.868-3.834zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 12px center;
}

/* Список пациентов врача */
.patient-list { list-style: none; margin: 0; padding: 0; }
.patient-list li { border-top: 1px solid var(--border); }
.patient-list li:first-child { border-top: 0; }
.patient-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 8px;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
}
.patient-list a:hover { background: var(--brand-soft); }
.patient-list .chevron { color: var(--muted); font-size: 18px; }
.empty-state { color: var(--muted); text-align: center; padding: 24px 8px; margin: 0; }

/* Таблицы */
.app-table { margin: 0; }
.app-table thead th, .app-table thead td {
    background: #f8fafc;
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .02em;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.app-table td, .app-table th { padding: 12px 14px; vertical-align: middle; border-color: var(--border); }
.app-table tbody tr:hover { background: #f8fbfe; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap .app-table tr:last-child td { border-bottom: 0; }

/* Бейдж вероятности ПГПТ */
.risk {
    border-radius: var(--radius);
    padding: 16px;
    background: var(--success-soft);
    color: var(--success);
}
.risk__value { font-size: 32px; font-weight: 700; line-height: 1; }
.risk__label { font-weight: 600; margin-top: 6px; }
.risk__hint { font-size: 13px; opacity: .8; margin-top: 2px; }
.risk--medium { background: var(--warning-soft); color: var(--warning); }
.risk--high { background: var(--danger-soft); color: var(--danger); }
.risk--none { background: var(--bg); color: var(--muted); }

/* Хронология анамнезов */
.timeline-year { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin: 14px 0 6px; }
.timeline-year:first-child { margin-top: 0; }
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.timeline a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
}
.timeline a:hover { border-color: var(--brand); background: var(--brand-soft); }
.timeline .prob { font-size: 13px; color: var(--muted); }

/* Переключатели графиков */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { display: none; }
.chip > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
}
.chip input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip input:checked + span .hint-icon { background: rgba(255, 255, 255, .25); color: #fff; }
.chart { width: 100%; height: 360px; }
.hint-icon {
    display: inline-flex;
    width: 18px; height: 18px;
    align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
    cursor: help;
}

/* Форма анамнеза */
.param-row {
    display: grid;
    grid-template-columns: 1fr 140px 70px;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid var(--border);
}
.param-row:first-child { border-top: 0; }
.param-row label { margin: 0; }
.param-row .unit { color: var(--muted); font-size: 13px; }
.param-row .required-mark { color: var(--danger); }
.check-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}
.check-row:first-child { border-top: 0; }
.check-row .form-check-input { margin-top: 3px; flex-shrink: 0; width: 1.15em; height: 1.15em; }
@media (max-width: 575.98px) {
    .param-row { grid-template-columns: 1fr 110px; }
    .param-row .unit { grid-column: 2; margin-top: -8px; }
}

/* Результаты анамнеза */
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}
.result-list li:first-child { border-top: 0; }
.result-list .val { font-weight: 600; white-space: nowrap; }
.result-list .val small { color: var(--muted); font-weight: 400; }

/* Расчётные показатели анамнеза */
.calc-out {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bg);
    font-size: 14px;
}
.calc-out--empty { color: var(--muted); }
.calc-out--ok { background: var(--success-soft); color: var(--success); }
.calc-out--warn { background: var(--warning-soft); color: var(--warning); }
.calc-out--bad { background: var(--danger-soft); color: var(--danger); }
.form-control.is-calculated, .form-control[readonly].is-calculated { background: var(--brand-soft); border-color: #b9d5ec; font-weight: 600; }
.calc-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-soft);
    border-radius: 4px;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Админка */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .filters { display: flex; gap: 12px; flex-wrap: wrap; }
.toolbar .filters .search-input { width: 280px; }
.hidden { display: none !important; }

/* Вход */
.login-page { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .logo { display: block; height: 72px; margin: 0 auto 8px; }
.login-card h1 { font-size: 20px; font-weight: 600; text-align: center; margin: 0 0 20px; }
.password-field { position: relative; }
.password-field .form-control { padding-right: 44px; }
.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    padding: 6px;
    line-height: 0;
}
.password-toggle img { width: 20px; height: 20px; opacity: .6; }
.input-group .toggle-password { cursor: pointer; }
.input-group .toggle-password img { width: 20px; height: 20px; }

/* Модальные окна */
.modal-content { border: 0; border-radius: var(--radius); }
.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }
