/* ===========================================
   CSS VARIABLES
   =========================================== */
:root {
    --primary: #4361ee;
    --primary-dark: #3651d4;
    --dark: #1a1a2e;
    --gray: #64748b;
    --light-gray: #f1f5f9;
    --border: #e2e8f0;
    --male-color: #3b82f6;
    --female-color: #ec4899;
}

/* ===========================================
   BASE STYLES
   =========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===========================================
   HERO SECTION
   =========================================== */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: white;
    padding: 3rem 0;
    text-align: center;
}

.hero__subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

/* ===========================================
   SEARCH FORM
   =========================================== */
.search-form {
    max-width: 600px;
    margin: 0 auto;
}

.search-form__wrapper {
    display: flex;
    gap: 0.5rem;
    background: white;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.search-form__input {
    flex: 1;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    outline: none;
    background: transparent;
}

.search-form__input::placeholder {
    color: #94a3b8;
}

.search-form__button {
    padding: 1rem 2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.search-form__button:hover {
    background: var(--primary-dark);
}

/* ===========================================
   STATS SECTION
   =========================================== */
.stats {
    padding: 2.5rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stats__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .stats__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stats__card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.stats__number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stats__label {
    font-size: 0.9rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

/* ===========================================
   LATEST SECTION
   =========================================== */
.latest {
    padding: 3rem 0;
    background: #f8fafc;
}

.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1.5rem;
}

.section-footer {
    text-align: center;
    margin-top: 1.5rem;
}

/* ===========================================
   DOGS GRID
   =========================================== */
.dogs-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dogs-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .dogs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .dogs-grid {
        grid-template-columns: 1fr;
    }
}

/* ===========================================
   DOG CARD
   =========================================== */
.dog-card {
    display: block;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
}

.dog-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    text-decoration: none;
}

.dog-card__image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    overflow: hidden;
}

.dog-card__image.male {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}

.dog-card__image.female {
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 100%);
}

.dog-card__image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dog-card__placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dog-card__placeholder .sex-icon {
    font-size: 3rem;
    opacity: 0.4;
}

.dog-card__info {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dog-card__name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===========================================
   SEX ICONS
   =========================================== */
.sex-icon {
    font-weight: bold;
    flex-shrink: 0;
}

.sex-icon.male {
    color: var(--male-color);
}

.sex-icon.female {
    color: var(--female-color);
}

/* ===========================================
   BUTTONS
   =========================================== */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

.btn:hover {
    text-decoration: none;
}

.btn--primary {
    background: var(--primary);
    color: #fff;
}

.btn--primary:hover {
    background: var(--primary-dark);
}

.btn--outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn--outline:hover {
    background: var(--primary);
    color: #fff;
}

/* ===========================================
   DOG PROFILE PAGE
   =========================================== */
.dog-profile {
    padding: 2rem 0;
    background: white;
    min-height: 60vh;
}

.dog-header {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

@media (max-width: 768px) {
    .dog-header {
        grid-template-columns: 1fr;
    }
}

.dog-photo-main {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dog-photo-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-photo-large {
    font-size: 5rem;
    color: #cbd5e1;
}

.no-photo-large.male {
    color: var(--male-color);
}

.no-photo-large.female {
    color: var(--female-color);
}

.dog-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dog-title .sex-icon {
    font-size: 1.5rem;
}

.dog-meta-table {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.meta-row {
    display: flex;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.meta-row:last-child {
    border-bottom: none;
}

.meta-label {
    width: 140px;
    color: var(--gray);
    font-size: 0.9rem;
}

.meta-value {
    flex: 1;
    font-weight: 500;
}

/* Parents Section */
.parents-section {
    margin-bottom: 2rem;
}

.parents-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.parents-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .parents-grid {
        grid-template-columns: 1fr;
    }
}

.parent-card {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1.25rem;
    border-left: 4px solid #cbd5e1;
}

.parent-card.sire {
    border-left-color: var(--male-color);
}

.parent-card.dam {
    border-left-color: var(--female-color);
}

.parent-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.parent-name {
    font-weight: 600;
    font-size: 1rem;
}

.parent-link {
    color: var(--dark);
}

.parent-link:hover {
    color: var(--primary);
}

.unknown {
    color: #94a3b8;
    font-style: italic;
}

/* Offspring Section */
.offspring-section {
    margin-bottom: 2rem;
}

.offspring-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.offspring-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

.offspring-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: 6px;
    color: var(--dark);
    transition: background 0.2s;
}

.offspring-card:hover {
    background: #e2e8f0;
    text-decoration: none;
}

/* Gallery */
.gallery-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* =====================================================
   DOG PAGE - The Breed Archive Style
   ===================================================== */

.dog-page {
    background: #f8fafc;
    min-height: 100vh;
}

/* Header */
.dog-page-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1.5rem 0;
}

.dog-titles-line {
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 0.25rem;
    letter-spacing: 0.5px;
}

.dog-name {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dog-quick-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.dog-quick-info .death-date {
    color: #94a3b8;
}

.dog-parents-line {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.dog-parents-line .parent-link {
    color: #3b82f6;
    text-decoration: none;
}

.dog-parents-line .parent-link:hover {
    text-decoration: underline;
}

/* Content Grid */
.dog-content-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    padding: 2rem 0;
}

@media (max-width: 768px) {
    .dog-content-grid {
        grid-template-columns: 1fr;
    }
}

/* Info Column */
.dog-info-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-block {
    background: #fff;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.info-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.info-value {
    color: #1e293b;
}

.info-link {
    color: #3b82f6;
    text-decoration: none;
}

.info-link:hover {
    text-decoration: underline;
}

/* Photo Column */
.dog-photo-column {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.photo-container {
    position: relative;
}

.main-photo {
    width: 100%;
    height: 400px;
    object-fit: contain;
    background: #f1f5f9;
}

.photo-nav {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,0.9);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.photo-nav-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0 0.5rem;
}

.photo-nav-btn:hover {
    color: #3b82f6;
}

.photo-counter {
    font-size: 0.875rem;
    color: #64748b;
}

.no-photo {
    height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #94a3b8;
}

.no-photo-icon {
    font-size: 4rem;
    opacity: 0.5;
}

/* Tabs */
.dog-tabs {
    display: flex;
    gap: 2rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 2rem;
}

.tab-link {
    padding: 1rem 0;
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-link:hover {
    color: #1e293b;
    text-decoration: none;
}

.tab-link.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.tab-count {
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.5rem;
}

/* Sections */
.content-section {
    margin-bottom: 3rem;
}

.content-section .section-title {
    font-size: 1.25rem;
    font-weight: 300;
    color: #94a3b8;
    text-align: center;
    letter-spacing: 2px;
    margin-bottom: 1rem;
}

.section-subtitle {
    text-align: center;
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 1rem;
}

/* Offspring */
.offspring-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.5rem;
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
}

.offspring-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    color: #3b82f6;
    text-decoration: none;
    border-radius: 4px;
}

.offspring-item:hover {
    background: #f1f5f9;
    text-decoration: none;
}

/* Pedigree Actions */
.pedigree-actions {
    text-align: center;
    margin-bottom: 1rem;
}

.link-action {
    color: #3b82f6;
    text-decoration: none;
    font-size: 0.875rem;
}

.link-action:hover {
    text-decoration: underline;
}

.pedigree-mini {
    background: #fff;
    border-radius: 8px;
    padding: 0.5rem;
    overflow-x: auto;
}

/* =====================================================
   PEDIGREE TREE - The Breed Archive Style (Horizontal)
   ===================================================== */

.pedigree-tree-horizontal {
    display: flex;
    gap: 4px;
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 8px;
    overflow-x: auto;
    align-items: stretch;
    min-height: 500px;
}

.ped-gen {
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: space-around;
    flex-shrink: 0;
}

/* Размеры колонок по поколениям */
.ped-gen-0 { min-width: 180px; }
.ped-gen-1 { min-width: 160px; }
.ped-gen-2 { min-width: 150px; }
.ped-gen-3 { min-width: 140px; }
.ped-gen-4 { min-width: 130px; }

/* Ячейка предка */
.ped-cell {
    background: white;
    border-radius: 6px;
    padding: 6px;
    border-left: 3px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-height: 50px;
    justify-content: center;
}

.ped-cell.ped-male {
    border-left-color: var(--male-color);
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.ped-cell.ped-female {
    border-left-color: var(--female-color);
    background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%);
}

.ped-cell.ped-empty {
    background: #f8fafc;
    border-left-color: #e2e8f0;
}

.ped-cell.ped-empty .ped-name {
    color: #94a3b8;
    font-style: italic;
}

.ped-cell.ped-current {
    border-left-width: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Фото в ячейках - ограничение по максимальной высоте */
.ped-photo {
    width: 100%;
    max-height: 100px;
    border-radius: 4px;
    overflow: hidden;
    background: #e2e8f0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ped-photo img {
    width: 100%;
    height: auto;
    max-height: 100px;
    object-fit: contain;
    object-position: center;
}

/* Разные лимиты по поколениям */
.ped-gen-0 .ped-photo,
.ped-gen-0 .ped-photo img {
    max-height: 120px;
}

.ped-gen-1 .ped-photo,
.ped-gen-1 .ped-photo img {
    max-height: 90px;
}

.ped-gen-2 .ped-photo,
.ped-gen-2 .ped-photo img {
    max-height: 75px;
}

.ped-photo-empty.ped-male {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: var(--male-color);
}

.ped-photo-empty.ped-female {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    color: var(--female-color);
}

/* Информация о предке */
.ped-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ped-titles {
    font-size: 0.6rem;
    color: #64748b;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
	max-width: 350px;
}

.ped-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: #1e293b;
    text-decoration: none;
    line-height: 1.3;
    display: block;
}

a.ped-name:hover {
    color: var(--primary);
    text-decoration: underline;
}

.ped-name-current {
    font-weight: 600;
    font-size: 0.8rem;
}

.ped-year {
    font-size: 0.65rem;
    color: #94a3b8;
}

.ped-icon {
    font-size: 1.2rem;
    text-align: center;
    padding: 0.5rem;
}

.ped-male .ped-icon { color: var(--male-color); }
.ped-female .ped-icon { color: var(--female-color); }

/* Поколения 3-4: без фото, компактнее */
.ped-gen-3 .ped-cell,
.ped-gen-4 .ped-cell {
    padding: 4px 6px;
    min-height: 35px;
}

.ped-gen-3 .ped-photo,
.ped-gen-4 .ped-photo {
    display: none;
}

.ped-gen-4 .ped-cell {
    font-size: 0.7rem;
}

.ped-gen-4 .ped-name {
    font-size: 0.65rem;
}

/* Адаптивность родословной */
@media (max-width: 1024px) {
    .pedigree-tree-horizontal {
        padding: 0.25rem;
    }
    
    .ped-gen-0 { min-width: 150px; }
    .ped-gen-1 { min-width: 130px; }
    .ped-gen-2 { min-width: 120px; }
    .ped-gen-3 { min-width: 110px; }
    .ped-gen-4 { min-width: 100px; }
}

@media (max-width: 768px) {
    .ped-gen-3,
    .ped-gen-4 {
        display: none;
    }
    
    .pedigree-tree-horizontal {
        min-height: 400px;
    }
}

/* Выбор количества поколений */
.pedigree-generations {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.pedigree-generations span {
    color: #64748b;
}

.pedigree-generations a {
    padding: 0.25rem 0.5rem;
    color: #64748b;
    text-decoration: none;
    border-radius: 4px;
}

.pedigree-generations a:hover,
.pedigree-generations a.active {
    background: var(--primary);
    color: white;
}

/* =====================================================
   PEDIGREE PAGE (Full page version)
   ===================================================== */

.pedigree-page {
    padding: 2rem 0;
}

.pedigree-header {
    margin-bottom: 2rem;
}

.pedigree-header h1 {
    margin: 0.5rem 0 0;
    font-size: 1.5rem;
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

/* Легенда */
.pedigree-legend {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.legend-item {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.legend-item.male { color: var(--male-color); }
.legend-item.female { color: var(--female-color); }
.legend-item.unknown { color: #94a3b8; }

/* =====================================================
   TEXT UTILITIES
   ===================================================== */

.text-muted {
    color: #94a3b8;
}


/* Утилиты */
.text-center {
    text-align: center;
}

/* =====================================================
   SIBLINGS SECTION
   ===================================================== */

.siblings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
}

.sibling-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s, box-shadow 0.2s;
}

.sibling-card:hover {
    background: #f1f5f9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-decoration: none;
}

.sibling-photo {
    width: 70px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sibling-photo.male {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.sibling-photo.female {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
}

.sibling-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sibling-placeholder {
    font-size: 1.75rem;
    opacity: 0.5;
}

.sibling-photo.male .sibling-placeholder {
    color: var(--male-color);
}

.sibling-photo.female .sibling-placeholder {
    color: var(--female-color);
}

.sibling-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.sibling-titles {
    font-size: 0.65rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.sibling-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sibling-meta {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    gap: 0.5rem;
    margin-top: 2px;
}

/* Утилиты */
.text-center {
    text-align: center;
}
/* ===========================================
   DOGS LIST PAGE
   =========================================== */

.page-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.page-header__title {
    font-size: 2rem;
    margin: 0 0 0.5rem;
}

.page-header__subtitle {
    margin: 0;
    opacity: 0.9;
}

/* Toolbar */
.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.list-toolbar__sort {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.list-toolbar__label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.sort-btn {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-muted);
    background: white;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.sort-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.sort-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.list-toolbar__info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Dogs Table */
.dogs-table {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.dog-row {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 1rem;
    padding: 1rem;
    background: white;
    align-items: center;
    transition: background 0.2s;
}

.dog-row:hover {
    background: var(--bg-light);
}

/* Photo */
.dog-row__photo {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.dog-row__photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dog-row__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: var(--bg-light);
}

.dog-row__placeholder.male {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: var(--male-color);
}

.dog-row__placeholder.female {
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%);
    color: var(--female-color);
}

/* Info */
.dog-row__info {
    min-width: 0;
}

.dog-row__header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.3rem;
}

.dog-row__name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.dog-row__name:hover {
    color: var(--primary);
}

.dog-row__titles {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-light);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.dog-row__parents {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.parent-link {
    color: var(--text-secondary);
}

.parent-link.male:hover {
    color: var(--male-color);
}

.parent-link.female:hover {
    color: var(--female-color);
}

.parent-link.unknown {
    color: var(--text-muted);
    font-style: italic;
}

.parent-separator {
    color: var(--text-muted);
    margin: 0 0.2rem;
}

.dog-row__meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Date column */
.dog-row__date {
    text-align: right;
    flex-shrink: 0;
}

.date-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.date-value {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    margin-top: 2rem;
    padding: 1rem 0;
}

.pagination__link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: white;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.pagination__link:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.pagination__link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination__dots {
    padding: 0 0.5rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .dog-row {
        grid-template-columns: 60px 1fr;
        grid-template-rows: auto auto;
    }
    
    .dog-row__photo {
        width: 60px;
        height: 60px;
        grid-row: span 2;
    }
    
    .dog-row__date {
        grid-column: 2;
        text-align: left;
        display: flex;
        gap: 0.5rem;
    }
    
    .date-label {
        display: inline;
    }
    
    .dog-row__titles {
        max-width: 150px;
    }
    
    .list-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}
/* Вся строка кликабельная */
.dog-row {
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease;
}

.dog-row:hover {
    background: #f8fafc;
}

/* Ссылка растягивается на всю строку */
.dog-row__name::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Ссылки внутри должны быть выше */
.dog-row__parents a,
.dog-row__info a:not(.dog-row__name) {
    position: relative;
    z-index: 2;
}
/* ===========================================
   KENNELS - Питомники
   =========================================== */

.kennels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kennel-card {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
}

.kennel-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.kennel-card__photo {
    height: 160px;
    overflow: hidden;
    background: #f1f5f9;
}

/* =====================================================
   PARENT SELECTOR AUTOCOMPLETE
   ===================================================== */

/* Контейнер с позиционированием */
.position-relative {
    position: relative;
}

/* Поле поиска родителя */
.parent-search {
    transition: border-color 0.2s, box-shadow 0.2s;
}

.parent-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.parent-search.selected {
    border-color: #22c55e;
    background-color: #f0fdf4;
}

.parent-search.loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm0 18a8 8 0 1 1 8-8 8 8 0 0 1-8 8z' opacity='.3'/%3E%3Cpath fill='%234361ee' d='M20 12h2A10 10 0 0 0 12 2v2a8 8 0 0 1 8 8z'%3E%3CanimateTransform attributeName='transform' dur='1s' from='0 12 12' repeatCount='indefinite' to='360 12 12' type='rotate'/%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

/* Выпадающий список результатов */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
}

.autocomplete-results.show {
    display: block;
}

/* Элемент результата */
.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

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

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: #f0f9ff;
}

.autocomplete-item.selected {
    background: #dbeafe;
}

/* Содержимое элемента */
.autocomplete-item__name {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 2px;
}

.autocomplete-item__meta {
    font-size: 0.8rem;
    color: var(--gray);
}

.autocomplete-item__sex {
    display: inline-block;
    margin-right: 4px;
}

.autocomplete-item__sex.male {
    color: var(--male-color);
}

.autocomplete-item__sex.female {
    color: var(--female-color);
}

/* Сообщения */
.autocomplete-message {
    padding: 12px 14px;
    color: var(--gray);
    font-size: 0.9rem;
    text-align: center;
}

.autocomplete-message.error {
    color: #dc2626;
    background: #fef2f2;
}

.autocomplete-message.loading {
    color: var(--primary);
}

/* Кнопка очистки */
.clear-parent {
    font-size: 0.8rem;
    cursor: pointer;
}

.clear-parent:hover {
    text-decoration: none;
}

/* Info под полем */
.sire-info,
.dam-info {
    display: block;
    margin-top: 4px;
}

/* ===========================================
   ШАПКА КАРТОЧКИ СОБАКИ (The Breed Archive style)
   =========================================== */

.dog-page-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    padding: 1.5rem 0;
    margin-bottom: 2rem;
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.header-main {
    flex: 1;
    min-width: 0;
}

/* Титулы */
.dog-titles-prefix {
    font-size: 0.75rem;
    color: #e67e22;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

/* Имя собаки */
.dog-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem 0;
    flex-wrap: wrap;
}

.dog-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: #212529;
    line-height: 1.2;
}

.sex-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: bold;
}

.sex-badge.male {
    background: #e3f2fd;
    color: #1976d2;
}

.sex-badge.female {
    background: #fce4ec;
    color: #c2185b;
}

.header-action-btn.edit-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 0.25rem;
}

.header-action-btn.edit-btn:hover {
    opacity: 1;
}

/* Мета-информация */
.dog-meta-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #495057;
    margin-bottom: 0.75rem;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.meta-symbol {
    font-weight: 600;
}

.meta-item.death {
    color: #6c757d;
}

.meta-separator {
    color: #adb5bd;
}

.country-flag {
    font-size: 1rem;
    margin-left: 0.25rem;
}

/* Родители */
.dog-parents-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #dee2e6;
}

.parent-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: #0d6efd;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.parent-link:hover {
    color: #0a58ca;
    text-decoration: underline;
}

.parent-unknown {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: #adb5bd;
    font-size: 0.95rem;
    font-style: italic;
}

.parents-separator {
    color: #6c757d;
    font-weight: 500;
    margin: 0 0.25rem;
}

.sex-icon {
    font-weight: bold;
}

.sex-icon.male {
    color: #1976d2;
}

.sex-icon.female {
    color: #c2185b;
}

/* Питомник и заводчик */
.dog-breeder-line {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #dee2e6;
    font-size: 0.875rem;
}

.breeder-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.breeder-label {
    color: #6c757d;
}

.breeder-link {
    color: #0d6efd;
    text-decoration: none;
}

.breeder-link:hover {
    text-decoration: underline;
}

/* Кнопки действий */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #f8f9fa;
    color: #495057;
    border-color: #adb5bd;
}

.action-btn.active,
.favorite-btn.active {
    color: #dc3545;
    border-color: #dc3545;
    background: #fff5f5;
}

.favorite-btn.active svg {
    fill: #dc3545;
}

/* Выпадающее меню */
.action-dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: #212529;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.dropdown-menu a:hover {
    background: #f8f9fa;
}

.dropdown-menu a.text-danger {
    color: #dc3545;
}

.dropdown-menu a.text-danger:hover {
    background: #fff5f5;
}

/* Адаптивность */
@media (max-width: 768px) {
    .header-top-row {
        flex-direction: column;
    }
    
    .header-actions {
        align-self: flex-start;
        margin-top: 1rem;
    }
    
    .dog-name {
        font-size: 1.5rem;
    }
    
    .dog-breeder-line {
        flex-direction: column;
        gap: 0.5rem;
    }
}





.toast-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ================================================
   ВКЛАДКИ (TABS) — улучшенная версия
   ================================================ */
.dog-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 2rem;
    padding-bottom: 0;
    /*overflow-x: auto;*/
    -webkit-overflow-scrolling: touch;
}

.tab-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    color: #6b7280;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-link:hover {
    color: #374151;
    background: #f9fafb;
    border-radius: 8px 8px 0 0;
}

.tab-link.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.tab-icon {
    font-size: 1.1rem;
}

.tab-text {
    display: inline;
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: #9ca3af;
    border-radius: 999px;
    transition: background 0.2s;
}

.tab-link.active .tab-badge {
    background: #2563eb;
}

.tab-link:hover .tab-badge {
    background: #6b7280;
}

/* Мобильная адаптация вкладок */
@media (max-width: 640px) {
    .dog-tabs {
        gap: 0.25rem;
    }
    
    .tab-link {
        padding: 0.75rem 0.875rem;
        font-size: 0.875rem;
    }
    
    .tab-text {
        display: none;
    }
    
    .tab-icon {
        font-size: 1.25rem;
    }
}

/* ================================================
   СЕКЦИИ КОНТЕНТА
   ================================================ */
.content-section {
    padding: 1.5rem 0;
}

.section-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.section-count {
    font-size: 0.875rem;
    color: #6b7280;
}

/* ================================================
   КАРТОЧКИ ОДНОПОМЁТНИКОВ
   ================================================ */
.siblings-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sibling-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.sibling-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* Цветовая индикация пола — левая граница */
.sibling-card.male {
    border-left: 3px solid #3b82f6;
}

.sibling-card.female {
    border-left: 3px solid #ec4899;
}

/* Фото однопомётника */
.sibling-photo {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    background: #f3f4f6;
}

.sibling-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sibling-photo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.sibling-photo-placeholder.male {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #2563eb;
}

.sibling-photo-placeholder.female {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    color: #db2777;
}

/* Информация */
.sibling-info {
    flex: 1;
    min-width: 0; /* для корректного обрезания текста */
}

.sibling-titles {
    font-size: 0.7rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sibling-name {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.25rem;
}

.sibling-sex-icon {
    font-size: 0.875rem;
    flex-shrink: 0;
}

.sibling-sex-icon.male {
    color: #3b82f6;
}

.sibling-sex-icon.female {
    color: #ec4899;
}

.sibling-name-text {
    font-weight: 600;
    font-size: 0.95rem;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sibling-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: #6b7280;
}

.sibling-meta span {
    white-space: nowrap;
}

.sibling-date::before {
    content: '📅 ';
    font-size: 0.7rem;
}

.sibling-color::before {
    content: '🎨 ';
    font-size: 0.7rem;
}

/* Стрелка */
.sibling-arrow {
    flex-shrink: 0;
    color: #d1d5db;
    transition: all 0.2s;
}

.sibling-card:hover .sibling-arrow {
    color: #9ca3af;
    transform: translateX(2px);
}

/* ================================================
   ПУСТОЕ СОСТОЯНИЕ
   ================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px dashed #e5e7eb;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1rem;
    color: #374151;
    margin-bottom: 0.25rem;
}

.empty-state-hint {
    font-size: 0.85rem;
    color: #9ca3af;
}

/* ================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ================================================ */
@media (max-width: 640px) {
    .sibling-card {
        padding: 0.875rem;
        gap: 0.75rem;
    }
    
    .sibling-photo {
        width: 52px;
        height: 52px;
    }
    
    .sibling-photo-placeholder {
        font-size: 1.25rem;
    }
    
    .sibling-name-text {
        font-size: 0.9rem;
    }
    
    .sibling-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.125rem;
    }
    
    .sibling-arrow {
        display: none;
    }
    
    .section-header {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* ================================================
   СЕКЦИЯ ПОТОМКОВ (обновлённая)
   ================================================ */
.offspring-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.5rem;
}

.offspring-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    color: #374151;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.offspring-item:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.offspring-item .sex-icon {
    font-size: 0.9rem;
}

.offspring-item .sex-icon.male {
    color: #3b82f6;
}

.offspring-item .sex-icon.female {
    color: #ec4899;
}

/* ═══════════════════════════════════════════════════════
   COI Widget — Виджет коэффициента инбридинга
   ═══════════════════════════════════════════════════════ */

.coi-widget {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.coi-widget:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Header */
.coi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.coi-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coi-icon {
    font-size: 1rem;
}

.coi-info-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: #9ca3af;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coi-info-btn:hover {
    background: #f3f4f6;
    color: #6b7280;
}

/* Main content */
.coi-main {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Большое значение COI */
.coi-value-block {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.coi-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--coi-color);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.coi-percent {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--coi-color);
    opacity: 0.7;
}

/* Прогресс-бар */
.coi-progress-container {
    width: 100%;
}

.coi-progress-bar {
    height: 8px;
    background: linear-gradient(to right, 
        #22c55e 0%, 
        #22c55e 12%, 
        #f59e0b 12%, 
        #f59e0b 25%, 
        #f97316 25%, 
        #f97316 50%, 
        #ef4444 50%, 
        #ef4444 100%
    );
    border-radius: 4px;
    position: relative;
    overflow: visible;
}

.coi-progress-fill {
    position: absolute;
    top: -3px;
    left: 0;
    width: 0;
    height: 14px;
    background: transparent;
    border-right: 3px solid var(--coi-color);
    border-radius: 0;
    transition: width 0.5s ease-out;
    box-shadow: 2px 0 4px rgba(0,0,0,0.2);
}

/* Маркеры уровней */
.coi-marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 12px;
    background: rgba(255,255,255,0.8);
    border-radius: 1px;
}

.coi-progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
    font-size: 0.65rem;
    color: #9ca3af;
}

/* Статус */
.coi-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--coi-bg);
    color: var(--coi-color);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    width: fit-content;
}

.coi-status-icon {
    font-size: 0.9rem;
}

/* Информационная панель */
.coi-info-panel {
    display: none;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    animation: slideDown 0.3s ease;
}

.coi-info-panel.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.coi-description {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0 0 0.75rem 0;
    line-height: 1.5;
}

/* Общие предки */
.coi-ancestors {
    margin-top: 0.75rem;
}

.coi-ancestors-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coi-ancestors-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.coi-ancestors-list li {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    padding: 0.375rem 0.5rem;
    background: #f9fafb;
    border-radius: 6px;
}

.ancestor-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.ancestor-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.ancestor-notation {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.65rem;
    color: #6b7280;
    background: #e5e7eb;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

.ancestor-contribution {
    font-size: 0.7rem;
    color: var(--coi-color);
    font-weight: 600;
    margin-left: auto;
}

/* Мета-информация */
.coi-meta {
    margin-top: 0.75rem;
    font-size: 0.7rem;
    color: #9ca3af;
}

/* ═══════════════════════════════════════════════════════
   Адаптивность
   ═══════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .coi-widget {
        padding: 0.875rem;
    }
    
    .coi-value {
        font-size: 2rem;
    }
    
    .coi-ancestors-list li {
        font-size: 0.75rem;
    }
}

/* ═══════════════════════════════════════════════════════
   Печать
   ═══════════════════════════════════════════════════════ */

@media print {
    .coi-info-btn {
        display: none;
    }
    
    .coi-info-panel {
        display: block !important;
    }
    
    .coi-widget {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ═══════════════════════════════════════════════════════
   COI WIDGET — КЛИКАБЕЛЬНАЯ ВЕРСИЯ
   ═══════════════════════════════════════════════════════ */

.coi-widget--clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.coi-widget--clickable:hover {
    border-color: var(--coi-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.coi-widget--clickable:focus {
    outline: none;
    border-color: var(--coi-color);
    box-shadow: 0 0 0 3px var(--coi-bg);
}

.coi-click-hint {
    color: #9ca3af;
    transition: color 0.2s;
}

.coi-widget--clickable:hover .coi-click-hint {
    color: var(--coi-color);
}

.coi-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #6b7280;
}

.coi-summary-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.coi-click-cta {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--coi-color);
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.coi-widget--clickable:hover .coi-click-cta {
    opacity: 1;
}

.coi-progress-track {
    position: relative;
}

.coi-progress-marker {
    position: absolute;
    top: -4px;
    width: 12px;
    height: 12px;
    background: var(--coi-color);
    border: 2px solid white;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* ═══════════════════════════════════════════════════════
   COI MODAL
   ═══════════════════════════════════════════════════════ */

.coi-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.coi-modal.show {
    opacity: 1;
    visibility: visible;
}

.coi-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.coi-modal__dialog {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s ease;
}

.coi-modal.show .coi-modal__dialog {
    transform: scale(1) translateY(0);
}

.coi-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.coi-modal__header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
}

.coi-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: #f3f4f6;
    border-radius: 8px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
}

.coi-modal__close:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.coi-modal__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.coi-modal__footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 16px 16px;
}

/* Hero секция */
.coi-modal__hero {
    text-align: center;
    padding: 1.5rem;
    background: var(--hero-bg);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.coi-modal__hero-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--hero-color);
    line-height: 1;
}

.coi-modal__hero-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--hero-color);
    margin-top: 0.5rem;
}

.coi-modal__hero-desc {
    font-size: 0.9rem;
    color: #6b7280;
    margin-top: 0.5rem;
}

/* Шкала */
.coi-modal__scale {
    margin-bottom: 1.5rem;
}

.coi-scale-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
}

.coi-scale-track {
    display: flex;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.coi-scale-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.coi-scale-zone--low { background: #22c55e; }
.coi-scale-zone--moderate { background: #f59e0b; }
.coi-scale-zone--high { background: #f97316; }
.coi-scale-zone--very-high { background: #ef4444; }

.coi-scale-label {
    font-weight: 600;
    line-height: 1.2;
}

.coi-scale-range {
    opacity: 0.9;
}

.coi-scale-marker {
    position: absolute;
    top: -8px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.coi-scale-marker-dot {
    width: 16px;
    height: 16px;
    background: #1f2937;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.coi-scale-marker-value {
    margin-top: 36px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1f2937;
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Полнота родословной */
.coi-modal__completeness {
    background: #f9fafb;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.coi-completeness-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.coi-completeness-title {
    font-weight: 600;
    color: #374151;
}

.coi-completeness-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
}

.coi-completeness-bar {
    height: 24px;
    background: #e5e7eb;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.coi-completeness-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 12px;
    transition: width 0.5s ease;
}

.coi-completeness-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: #1f2937;
}

.coi-completeness-lines {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.coi-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.coi-line-icon {
    font-weight: bold;
}

.coi-line-icon.male { color: #3b82f6; }
.coi-line-icon.female { color: #ec4899; }

.coi-line-label {
    color: #6b7280;
}

.coi-line-value {
    font-weight: 600;
    color: #374151;
}

/* Общие предки */
.coi-modal__ancestors {
    margin-bottom: 1.5rem;
}

.coi-ancestors-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.coi-ancestors-title {
    font-weight: 600;
    color: #374151;
}

.coi-ancestors-hint {
    font-size: 0.75rem;
    color: #9ca3af;
}

.coi-ancestors-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.coi-ancestor-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 8px;
    transition: background 0.2s;
}

.coi-ancestor-item:hover {
    background: #f3f4f6;
}

.coi-ancestor-rank {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    flex-shrink: 0;
}

.coi-ancestor-info {
    flex: 1;
    min-width: 0;
}

.coi-ancestor-name {
    font-weight: 500;
    color: #1f2937;
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.coi-ancestor-name:hover {
    color: #3b82f6;
    text-decoration: underline;
}

.coi-ancestor-meta {
    font-size: 0.75rem;
    color: #9ca3af;
}

.coi-ancestor-contribution {
    text-align: right;
    flex-shrink: 0;
}

.coi-contribution-value {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.coi-contribution-bar {
    width: 60px;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.coi-contribution-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    border-radius: 2px;
}

.coi-ancestors-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
    background: none;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    color: #6b7280;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.coi-ancestors-toggle:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #374151;
}

.coi-ancestors-toggle svg {
    transition: transform 0.2s;
}

.coi-ancestors-toggle.expanded svg {
    transform: rotate(180deg);
}

/* Информационный блок */
.coi-modal__info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 1rem;
}

.coi-info-title {
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 0.5rem;
}

.coi-info-text {
    font-size: 0.85rem;
    color: #374151;
    line-height: 1.6;
}

.coi-info-text p {
    margin: 0 0 0.5rem 0;
}

.coi-info-text p:last-child {
    margin-bottom: 0;
}

.coi-info-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #bfdbfe;
    font-size: 0.8rem;
    color: #6b7280;
}

/* Кнопки футера */
.coi-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
}

.coi-modal__btn--secondary {
    background: #e5e7eb;
    color: #374151;
}

.coi-modal__btn--secondary:hover {
    background: #d1d5db;
}

.coi-modal__btn--primary {
    background: #3b82f6;
    color: white;
}

.coi-modal__btn--primary:hover {
    background: #2563eb;
}

/* Адаптивность */
@media (max-width: 640px) {
    .coi-modal__dialog {
        width: 95%;
        max-height: 95vh;
        margin: 1rem;
    }
    
    .coi-modal__header {
        padding: 1rem;
    }
    
    .coi-modal__header h2 {
        font-size: 1.1rem;
    }
    
    .coi-modal__body {
        padding: 1rem;
    }
    
    .coi-modal__hero-value {
        font-size: 2.5rem;
    }
    
    .coi-scale-zone {
        font-size: 0.55rem;
    }
    
    .coi-scale-label {
        display: none;
    }
    
    .coi-completeness-lines {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .coi-ancestor-item {
        padding: 0.5rem;
    }
    
    .coi-ancestor-name {
        font-size: 0.9rem;
    }
    
    .coi-contribution-bar {
        width: 40px;
    }
    
    .coi-modal__footer {
        flex-direction: column;
        padding: 1rem;
    }
    
    .coi-modal__btn {
        width: 100%;
    }
}

/* Скрытие элементов по умолчанию */
.coi-ancestor-hidden {
    display: none;
}
