/* ============================================================
   Medical Admin — редизайн: sidebar + main
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    font-size: 15px;
    line-height: 1.5;
}

/* ============================================================
   LAYOUT: sidebar + main
   ============================================================ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #1f2937;
    color: #d1d5db;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px;
    border-bottom: 1px solid #374151;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}
.brand-icon { font-size: 1.4rem; }
.brand-text { letter-spacing: .3px; }

.sidebar-nav {
    flex: 1;
    padding: 14px 0;
    overflow-y: auto;
}

.nav-section {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #6b7280;
    padding: 14px 22px 6px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    color: #d1d5db;
    text-decoration: none;
    font-size: .93rem;
    border-left: 3px solid transparent;
    transition: background .12s, color .12s, border-color .12s;
}
.nav-link:hover {
    background: #374151;
    color: #fff;
}
.nav-link.active {
    background: #111827;
    color: #fff;
    border-left-color: #3b82f6;
    font-weight: 600;
}
.nav-icon {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid #374151;
    padding: 16px 18px;
}
.user-block {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-name {
    color: #fff;
    font-size: .88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    color: #9ca3af;
    font-size: .78rem;
}

.btn-logout {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: #374151;
    color: #f3f4f6;
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    font-size: .85rem;
    font-weight: 500;
    transition: background .12s;
}
.btn-logout:hover { background: #dc2626; color: #fff; }

/* ============================================================
   MAIN
   ============================================================ */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #f3f4f6;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
}
.topbar-meta {
    font-size: .85rem;
    color: #6b7280;
}

.content {
    flex: 1;
    padding: 24px 32px 40px;
    max-width: 1400px;
    width: 100%;
}

/* ============================================================
   CARDS
   ============================================================ */
.auth-card {
    background: #fff;
    padding: 28px 32px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
    margin-bottom: 20px;
}
.auth-card h2 {
    margin-bottom: 18px;
    color: #111827;
    font-size: 1.35rem;
}
.auth-card h3 {
    margin-top: 22px;
    margin-bottom: 12px;
    color: #111827;
    font-size: 1.05rem;
    font-weight: 600;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}
.form-group label {
    font-size: .88rem;
    color: #374151;
    margin-bottom: 6px;
    font-weight: 500;
}

.input {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;
    color: #111827;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
.input:focus {
    outline: none;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
.input::placeholder { color: #9ca3af; }

textarea.input {
    min-height: 180px;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: .85rem;
    line-height: 1.4;
    resize: vertical;
}

select.input {
    cursor: pointer;
}

.err {
    color: #dc2626;
    font-size: .82rem;
    margin-top: 4px;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: .92rem;
    color: #374151;
    cursor: pointer;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background .15s, box-shadow .15s;
    line-height: 1.2;
}
.btn-primary { background: #1d4ed8; color: #fff; }
.btn-primary:hover { background: #1e40af; }

.btn-secondary { background: #6b7280; color: #fff; }
.btn-secondary:hover { background: #4b5563; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-small { padding: 6px 12px; font-size: .85rem; }

.btn-block { display: block; width: 100%; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: .92rem;
    border: 1px solid transparent;
}
.alert-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* ============================================================
   TABLES
   ============================================================ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.table th, .table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}
.table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
}
.table th a {
    color: #374151;
    text-decoration: none;
}
.table th a:hover { color: #1d4ed8; }
.table tr:hover { background: #f9fafb; }

.table-wrap {
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.table-wrap .table { margin: 0; }
.table-wrap .table th:first-child,
.table-wrap .table td:first-child { padding-left: 16px; }
.table-wrap .table th:last-child,
.table-wrap .table td:last-child { padding-right: 16px; }

.mono {
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: .84rem;
    white-space: nowrap;
}

.ua { color: #6b7280; font-size: .82rem; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { padding: 3px 9px; border-radius: 6px; font-size: .78rem; font-weight: 500; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* ============================================================
   STATS
   ============================================================ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0 24px;
}
.stat {
    background: #f9fafb;
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid #e5e7eb;
}
.stat-value { font-size: 1.7rem; font-weight: 700; color: #111827; }
.stat-label { font-size: .82rem; color: #6b7280; margin-top: 4px; }
.stat-success { background: #ecfdf5; border-color: #a7f3d0; }
.stat-success .stat-value { color: #065f46; }
.stat-danger  { background: #fef2f2; border-color: #fecaca; }
.stat-danger .stat-value { color: #991b1b; }
.stat-warning { background: #fffbeb; border-color: #fde68a; }
.stat-warning .stat-value { color: #92400e; }

/* ============================================================
   FILTERS
   ============================================================ */
.filters, .analyzes-filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.filters .input, .analyzes-filters .input {
    flex: 1 1 200px;
    min-width: 160px;
}
.analyzes-filters select.input { max-width: 320px; }
.filters .btn, .analyzes-filters .btn {
    width: auto;
    padding: 10px 16px;
    flex: 0 0 auto;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}
.page-btn {
    padding: 7px 12px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-decoration: none;
    color: #374151;
    font-size: .88rem;
    transition: background .12s, border-color .12s;
}
.page-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}
.page-btn.disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}
.page-info {
    padding: 0 12px;
    color: #6b7280;
    font-size: .88rem;
}

/* ============================================================
   PROFILE
   ============================================================ */
.profile-info {
    margin: 20px 0;
    border-top: 1px solid #e5e7eb;
}
.profile-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 4px;
    border-bottom: 1px solid #e5e7eb;
    gap: 16px;
}
.profile-row .label { color: #6b7280; font-size: .9rem; }
.profile-row .value {
    color: #111827;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}
.actions .btn { width: auto; }

/* ============================================================
   DICTIONARIES MENU
   ============================================================ */
.dict-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}
.dict-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 20px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    transition: background .15s, border-color .15s;
}
.dict-item:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}
.dict-icon {
    font-size: 1.8rem;
    width: 44px;
    text-align: center;
    flex-shrink: 0;
}
.dict-info { flex: 1; }
.dict-title { font-weight: 600; font-size: 1.02rem; color: #111827; }
.dict-sub { font-size: .85rem; color: #6b7280; margin-top: 4px; }
.dict-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ============================================================
   ANALYZE VIEW
   ============================================================ */
.analyze-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}
.analyze-header h2 { margin-bottom: 6px; }
.analyze-id {
    color: #6b7280;
    font-size: .85rem;
    white-space: nowrap;
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

.analyze-link {
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 500;
}
.analyze-link:hover { text-decoration: underline; }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f3f4f6;
    border-radius: 8px;
    cursor: pointer;
    font-size: .92rem;
    color: #374151;
    border: 1px solid transparent;
}
.tab:hover { background: #e5e7eb; }
.tab input[type="radio"] { margin: 0; cursor: pointer; }
.tab input[type="radio"]:checked + span { font-weight: 600; color: #1d4ed8; }

/* ============================================================
   AUTH CARDS
   ============================================================ */
.auth-narrow {
    max-width: 460px;
    margin: 40px auto;
}

/* ============================================================
   CDA документы
   ============================================================ */
.cda-text {
    margin: 12px 0;
    overflow-x: auto;
}
.cda-text table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
    margin: 10px 0;
}
.cda-text table th,
.cda-text table td {
    padding: 7px 10px;
    border: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}
.cda-text table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    font-size: .82rem;
}
.cda-text table td { color: #111827; }
.cda-text strong { font-weight: 700; }

.row-high { background: #fef2f2; }
.row-low  { background: #eff6ff; }
.row-high td, .row-low td { font-weight: 500; }

h4 { color: #374151; font-weight: 600; }

/* ===== CDA документы — сетка шапки ===== */
.doc-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 800px) {
    .doc-meta-grid { grid-template-columns: 1fr; }
}

.doc-meta-block h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #111827;
    font-size: 1rem;
    font-weight: 600;
}

/* Результаты */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}
.results-header h3 {
    margin: 0;
    font-size: 1.05rem;
}
.results-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.result-name {
    font-weight: 500;
    color: #111827;
    line-height: 1.35;
}

.results-table td:first-child {
    max-width: 420px;
}

/* Образцы */
.specimens-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}
.specimens-list li {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: .92rem;
}
.specimens-list li:last-child { border-bottom: none; }

/* ===== Фильтры-бейджи ===== */
.filter-badge {
    cursor: pointer;
    text-decoration: none;
    transition: transform .1s, box-shadow .15s;
    display: inline-block;
}
.filter-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.filter-badge.active {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    font-weight: 700;
}
.filter-reset {
    background: #f3f4f6;
    color: #6b7280;
}
.filter-reset:hover {
    background: #e5e7eb;
    color: #111827;
}

/* ===== Тулбар списка документов ===== */
.documents-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.documents-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.documents-actions .btn {
    width: auto;
    padding: 9px 16px;
}

/* ===== Диагнозы ===== */
.diagnosis-item {
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
    line-height: 1.5;
}
.diagnosis-item:last-child { border-bottom: none; }
.diagnosis-code {
    margin-left: 8px;
    color: #1d4ed8;
    font-weight: 700;
    font-size: .95rem;
}
.diagnosis-name {
    margin-left: 8px;
    color: #111827;
}

/* ===== Клинические секции (анамнез, жалобы, рекомендации) ===== */
.clinical-label {
    font-weight: 600;
    color: #374151;
    font-size: .88rem;
    margin-top: 10px;
    margin-bottom: 4px;
}
.clinical-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #111827;
    font-size: .92rem;
    line-height: 1.55;
    padding: 10px 14px;
    background: #f9fafb;
    border-left: 3px solid #93c5fd;
    border-radius: 6px;
    margin-top: 6px;
}

/* ===== Динамика показателей ===== */
.dynamics-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 1000px) {
    .dynamics-layout { grid-template-columns: 1fr; }
}

/* --- Фильтры --- */
.dynamics-filters {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e5e7eb;
}
.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-group-label {
    color: #6b7280;
    font-size: .85rem;
    font-weight: 500;
}
.filter-spacer { flex: 1; }

.filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    background: #f3f4f6;
    color: #374151;
    border-radius: 20px;
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: background .12s, color .12s, transform .08s;
    border: 1px solid #e5e7eb;
    white-space: nowrap;
    cursor: pointer;
}
.filter-chip:hover {
    background: #e5e7eb;
    color: #111827;
    transform: translateY(-1px);
}
.filter-chip.active {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
    font-weight: 600;
}
.filter-chip.chip-abnormal {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}
.filter-chip.chip-abnormal:hover {
    background: #fee2e2;
}
.filter-chip.chip-abnormal.active {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}
.filter-chip-sm {
    padding: 5px 12px;
    font-size: .82rem;
    min-width: 44px;
    justify-content: center;
}

/* --- Сетка графиков --- */
.dynamics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
@media (max-width: 1100px) {
    .dynamics-grid { grid-template-columns: 1fr; }
}

.dynamics-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
    padding: 18px 22px;
    border-left: 4px solid #e5e7eb;
    transition: box-shadow .15s;
}
.dynamics-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
}
.dynamics-card.has-abnormal {
    border-left-color: #dc2626;
}

.dynamics-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 10px;
}
.dynamics-card-heading {
    flex: 1;
    min-width: 0;
}
.dynamics-card-title {
    font-size: .94rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
    margin: 0 0 6px;
    word-wrap: break-word;
}
.dynamics-card-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: .75rem;
}
.dynamics-card-meta .mono { font-size: .75rem; }

.dynamics-card-last {
    text-align: right;
    flex-shrink: 0;
    min-width: 90px;
}
.dynamics-last-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.1;
}
.dynamics-last-value.val-high { color: #dc2626; }
.dynamics-last-value.val-low  { color: #2563eb; }
.dynamics-last-badge {
    margin-top: 2px;
    min-height: 18px;
}
.dynamics-last-badge .badge {
    font-size: .7rem;
    padding: 2px 6px;
}
.dynamics-last-date {
    font-size: .7rem;
    margin-top: 2px;
}

.dynamics-chart-wrap {
    background: #fafbfc;
    border-radius: 8px;
    padding: 10px 8px;
    margin-bottom: 8px;
}

.dynamics-toggle {
    width: 100%;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #1d4ed8;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background .12s;
}
.dynamics-toggle:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.dynamics-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
}

.table-compact {
    font-size: .82rem;
}
.table-compact th,
.table-compact td {
    padding: 6px 8px;
}

/* ===== Печать ===== */
@media print {
    .sidebar, .topbar, .dynamics-filters, .actions, .filter-chip,
    .dynamics-toggle, button {
        display: none !important;
    }
    .layout { display: block; }
    .content { padding: 0; max-width: 100%; }
    .dynamics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .dynamics-card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .dynamics-details { display: block !important; }
    .auth-card {
        box-shadow: none;
        padding: 10px;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .sidebar { width: 220px; }
    .content { padding: 20px 20px 32px; }
    .topbar { padding: 14px 20px; }
}

@media (max-width: 700px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }
    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        padding: 10px;
        gap: 4px;
    }
    .nav-section { display: none; }
    .nav-link {
        padding: 8px 14px;
        border-left: none;
        border-radius: 6px;
        background: #374151;
    }
    .nav-link.active { background: #3b82f6; }
    .sidebar-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 14px;
    }
    .user-block { margin-bottom: 0; }
    .btn-logout { width: auto; padding: 6px 14px; }
    .content { padding: 16px 14px 24px; }
    .topbar { padding: 12px 14px; }
}

/* ===== Динамика — сетка графиков ===== */
.dynamics-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e5e7eb;
}
.dynamics-sep {
    color: #6b7280;
    font-size: .85rem;
    margin-left: 8px;
}
.filter-chip {
    display: inline-block;
    padding: 6px 14px;
    background: #f3f4f6;
    color: #374151;
    border-radius: 20px;
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: background .12s, color .12s;
    border: 1px solid transparent;
}
.filter-chip:hover {
    background: #e5e7eb;
    color: #111827;
}
.filter-chip.active {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
}

.dynamics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
@media (max-width: 1100px) {
    .dynamics-grid { grid-template-columns: 1fr; }
}

.dynamics-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
    padding: 20px 24px;
    border-left: 4px solid #e5e7eb;
    transition: box-shadow .15s;
}
.dynamics-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
}
.dynamics-card.has-abnormal {
    border-left-color: #dc2626;
}

.dynamics-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}
.dynamics-card-title {
    font-size: .95rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
    margin: 0 0 4px;
}
.dynamics-card-last {
    text-align: right;
    flex-shrink: 0;
}
.dynamics-last-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.1;
}
.dynamics-last-value.val-high { color: #dc2626; }
.dynamics-last-value.val-low  { color: #2563eb; }

.dynamics-chart-wrap {
    background: #fafbfc;
    border-radius: 8px;
    padding: 14px 12px;
    margin-bottom: 8px;
}

.dynamics-details {
    margin-top: 8px;
}
.dynamics-details summary {
    cursor: pointer;
    color: #1d4ed8;
    font-size: .85rem;
    font-weight: 500;
    padding: 6px 0;
    user-select: none;
}
.dynamics-details summary:hover {
    text-decoration: underline;
}
.dynamics-details[open] summary {
    margin-bottom: 8px;
}

.table-compact {
    font-size: .82rem;
}
.table-compact th,
.table-compact td {
    padding: 6px 8px;
}

/* ===== Печать ===== */
@media print {
    .sidebar, .topbar, .dynamics-filters, .actions, .filter-chip,
    .dynamics-details summary, button {
        display: none !important;
    }
    .layout { display: block; }
    .content { padding: 0; max-width: 100%; }
    .dynamics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .dynamics-card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .auth-card {
        box-shadow: none;
        padding: 10px;
    }
}

/* ===== Аналитика: находки ===== */
.findings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.finding-item {
    padding: 14px 18px;
    border-radius: 10px;
    background: #f9fafb;
    border-left: 4px solid #93c5fd;
}
.finding-item.finding-urgent   { border-left-color: #f59e0b; background: #fffbeb; }
.finding-item.finding-critical { border-left-color: #dc2626; background: #fef2f2; }

.finding-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.finding-title {
    font-weight: 600;
    color: #111827;
    font-size: 1rem;
}
.finding-urgency {
    margin-left: auto;
    font-size: .8rem;
}
.finding-desc {
    color: #374151;
    font-size: .92rem;
    margin-bottom: 6px;
}
.finding-values {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .78rem;
}
.finding-value {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 2px 8px;
    border-radius: 6px;
}

.badge-warning { background: #fef3c7; color: #92400e; }

.patients-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
