/* === IRG CUSTOM: mod_repo_search === */
.repo-search-module { width: 100%; }

/* Поле пошуку — по центру правої колонки, помірної ширини */
.repo-search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 720px;
    margin: 0 auto 4px;
}

/* Обгортка інпута — носій для абсолютного спінера (щоб він тримався
   правого краю САМЕ поля, а не всього боксу, де поруч кнопка «Фільтри»). */
.repo-input-wrap{
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
}

.repo-search-input {
    width: 100%;
    padding: 14px 44px 14px 18px;
    font-size: 1.05rem;
    line-height: 1.4;
    border: 2px solid #1778ba;
    border-radius: 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    background: #fff;
    box-shadow: 0 1px 3px rgba(23,120,186,.12);
}
.repo-search-input::placeholder { color: #8a97a4; }
.repo-search-input:focus {
    border-color: #1a90d9;
    box-shadow: 0 0 0 3px rgba(26,144,217,.20);
}

.repo-search-spinner {
    display: none;
    position: absolute;
    right: 14px;
    width: 18px;
    height: 18px;
    border: 2px solid #cfd8e3;
    border-top-color: #1a90d9;
    border-radius: 50%;
    animation: repo-spin .7s linear infinite;
}
@keyframes repo-spin { to { transform: rotate(360deg); } }

.repo-search-results { margin-top: 16px; }

.repo-search-count {
    font-weight: 600;
    color: #333;
    margin: 4px 0 12px;
}

.repo-search-hint,
.repo-search-empty,
.repo-search-error {
    padding: 12px 4px;
    color: #667;
    font-size: .95rem;
}
.repo-search-error { color: #b23; }

@media (prefers-reduced-motion: reduce) {
    .repo-search-spinner { animation: none; }
    .repo-search-input   { transition: none; }
}

/* ===== Розкладка: постійна ліва колонка фільтрів + широка права ===== */
.repo-search-body{
    display:grid;
    grid-template-columns:280px minmax(0, 1fr);
    align-items:start;
    gap:24px;
}
.repo-search-main{min-width:0}  /* min-width:0 щоб картки коректно стискались */

/* бічна панель: статична, завжди видима */
.repo-filter-panel{
    border:1px solid #b8c4d0;border-radius:4px;background:#f4f7fa;
    padding:16px 18px 16px 20px;
    position:sticky;top:16px;      /* легко «прилипає» при прокрутці */
    align-self:start;
    /* IRG v1.26.1: панель не вища за екран і має власну прокрутку —
       тоді sticky справді працює, а фільтри гортаються незалежно від результатів */
    max-height:calc(100vh - 32px);
    overflow-y:auto;
    overscroll-behavior:contain;   /* докрутивши панель, не гортаємо сторінку */
    scrollbar-width:none;          /* IRG v1.26.3: прокрутка є, смуги немає (Firefox) */
}
.repo-filter-panel::-webkit-scrollbar{display:none}  /* Chrome, Edge, Safari */

/* шапка панелі */
.repo-filter-head{
    display:flex;align-items:center;justify-content:space-between;
    margin-bottom:12px;padding-bottom:10px;border-bottom:1px solid #d8e0e8;
    /* IRG v1.26.1: шапка з «Скинути» лишається видимою при прокрутці панелі */
    position:sticky;top:-16px;z-index:2;
    background:#f4f7fa;
    margin-top:-16px;padding-top:16px;
}
.repo-filter-head-actions{display:inline-flex;align-items:center;gap:10px}
.repo-filter-title{font-weight:700;color:#1778ba;font-size:1.05rem}

/* група фільтра: підпис зверху, chips під ним */
.repo-fgroup{margin-bottom:16px}
.repo-fgroup:last-of-type{margin-bottom:0}
.repo-flabel{
    display:block;margin-bottom:8px;
    font-weight:700;color:#555;font-size:.85rem;
    text-transform:uppercase;letter-spacing:.02em;
}
.repo-chips{display:flex;flex-wrap:wrap;gap:6px}

/* chips столбиком на всю ширину (Категорія, Видання ІРГ) */
.repo-chips--stack{flex-direction:column;align-items:stretch}
.repo-chips--stack .repo-chip{
    width:100%;
    align-items:flex-start;       /* крапка зверху, якщо текст у 2 рядки */
    justify-content:flex-start;   /* крапка + текст зліва */
    text-align:left;
    white-space:normal;           /* довгі назви переносяться */
    line-height:1.3;
}
.repo-chips--stack .repo-chip::before{margin-top:5px}

/* IRG v1.26.4: згорнутий список категорій — зайві приховані,
   але вибрані лишаються видимими, щоб активний фільтр не «зникав» */
.repo-chips--collapsed .repo-chip--extra:not(.active){display:none}
.repo-more-toggle{
    display:block;margin-top:6px;padding:2px 0;
    background:none;border:none;cursor:pointer;
    color:#1778ba;font-size:.85rem;font-family:inherit;text-decoration:underline;
}
.repo-more-toggle:hover{color:#0f5a8c}

/* IRG v1.26.5: кількість записів у чіпі (праворуч, сірим) */
.repo-chip-txt{flex:1 1 auto;min-width:0}
.repo-chip-num{
    flex:0 0 auto;margin-left:auto;padding-left:6px;
    font-size:.78rem;font-weight:400;color:#8a97a4;
    font-variant-numeric:tabular-nums;
}
.repo-chip.active .repo-chip-num{color:#1778ba}

/* чіп — Варіант 2: крапка-індикатор зліва + свічення у вибраного.
   М'які сірі рамки у спокої; активний — синій текст, легка підсвітка,
   синя «лампочка» зі свіченням і м'яке кільце навколо. */
.repo-chip{
    display:inline-flex;align-items:center;gap:8px;
    padding:6px 12px 6px 11px;font-size:.85rem;
    border:1px solid #d3dbe4;background:#fff;color:#2c3e50;
    border-radius:6px;cursor:pointer;
    font-family:'Roboto Condensed',sans-serif;
    transition:.15s;
}
.repo-chip::before{
    content:"";flex:0 0 auto;
    width:7px;height:7px;border-radius:50%;
    background:#cdd6df;transition:.15s;
}
.repo-chip:hover{border-color:#1778ba;background:#f4f9fc}
.repo-chip.active{
    border-color:#1778ba;color:#1778ba;font-weight:600;
    background:#e8f2f9;
    box-shadow:0 0 0 3px rgba(23,120,186,.12);
}
.repo-chip.active::before{
    background:#1778ba;
    box-shadow:0 0 5px rgba(23,120,186,.8);
}

/* підвал панелі */
.repo-filter-foot{
    margin-top:16px;padding-top:12px;border-top:1px solid #d8e0e8;
}
.repo-filter-summary{display:block;font-size:.8rem;color:#555;margin-bottom:6px}
.repo-filter-clear{
    background:none;border:none;color:#1778ba;cursor:pointer;
    font-size:.85rem;text-decoration:underline;font-family:inherit;padding:0;
    white-space:nowrap;
}
.repo-filter-clear[hidden]{display:none}

/* ===== Кнопка «Фільтри», хрестик і бекдроп — лише мобільний оверлей =====
   На десктопі приховані (панель статична зліва). */
.repo-filter-toggle{ display:none; }
.repo-filter-close{ display:none; }
.repo-filter-backdrop{ display:none; }

/* --- Мобільний: панель ховається за кнопку «Фільтри», виїжджає оверлеєм --- */
@media (max-width:768px){
    /* одна колонка: лишається тільки права (пошук + результати) */
    .repo-search-body{
        display:block;
    }

    /* Рядок пошуку: поле (у своїй обгортці) + кнопка «Фільтри» в один ряд */
    .repo-search-box{
        max-width:none;   /* на всю ширину екрана */
        gap:8px;
    }
    .repo-input-wrap{flex:1 1 auto;min-width:0}

    /* Кнопка-тригер праворуч від поля пошуку */
    .repo-filter-toggle{
        display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;
        padding:0 14px;height:auto;align-self:stretch;
        border:1px solid #b8c4d0;border-radius:10px;background:#fff;color:#1778ba;
        font-family:inherit;font-size:.95rem;cursor:pointer;white-space:nowrap;
    }
    .repo-filter-toggle:hover{background:#e8f2f9;border-color:#1778ba}
    .repo-filter-count{
        display:inline-flex;align-items:center;justify-content:center;
        min-width:20px;height:20px;padding:0 6px;border-radius:10px;
        background:#1778ba;color:#fff;font-size:.8rem;font-weight:600;
    }
    .repo-filter-count[hidden]{display:none}

    /* Панель — оверлей зліва на всю висоту вьюпорта, зі своєю прокруткою.
       Висоту беремо 100dvh (динамічний вьюпорт: враховує тулбар браузера),
       з фолбеком 100vh для старих браузерів. Знизу — safe-area + запас,
       щоб останній фільтр / кнопка CSV не ховались за краєм екрана. */
    .repo-filter-panel{
        position:fixed;left:0;top:0;z-index:1050;
        width:86vw;max-width:340px;
        height:100vh;height:100dvh;
        margin:0;border:0;border-radius:0;
        overflow-y:auto;-webkit-overflow-scrolling:touch;
        box-shadow:2px 0 18px rgba(0,0,0,.28);
        transform:translateX(-100%);
        transition:transform .22s ease;
        padding:16px 18px calc(24px + env(safe-area-inset-bottom, 0px)) 20px;
    }
    .repo-filters-open .repo-filter-panel{
        transform:translateX(0);
    }
    /* Додатковий запас під останнім блоком у панелі */
    .repo-filter-panel .repo-filter-foot{margin-bottom:8px}

    /* Хрестик закриття у шапці панелі */
    .repo-filter-close{
        display:inline-flex;align-items:center;justify-content:center;
        border:none;background:none;font-size:1.6rem;line-height:1;
        color:#8a97a4;cursor:pointer;padding:0 4px;
    }
    .repo-filter-close:hover{color:#1778ba}

    /* Затемнення фону під панеллю */
    .repo-filter-backdrop{
        display:block;position:fixed;inset:0;z-index:1040;
        background:rgba(0,0,0,.45);
    }
    .repo-filter-backdrop[hidden]{display:none}

    /* Блок прокрутки сторінки, поки відкрито панель */
    body.repo-filters-lock{overflow:hidden}
}

/* На дуже вузьких екранах підпис лишаємо — сама іконка воронки відвідувачу
   нічого не каже. Місце звільняємо за рахунок поля пошуку. */
@media (max-width:420px){
    .repo-filter-toggle{padding:0 10px;font-size:.9rem;gap:5px}
    .repo-filter-toggle-txt{display:inline}
    .repo-search-box input[type="search"],
    .repo-search-box input[type="text"]{min-width:0}
}

/* Кнопка експорту CSV у панелі фільтрів */
.repo-csv-btn{
    display:inline-flex;align-items:center;gap:7px;
    margin-top:12px;padding:8px 14px;width:100%;justify-content:center;
    background:#27ae60;color:#fff;border:none;border-radius:6px;
    font-family:inherit;font-size:.9rem;cursor:pointer;
    transition:background .15s;
}
.repo-csv-btn:hover{background:#2ecc71}
.repo-csv-btn:disabled{background:#8bc9a6;cursor:default}

/* Чіп-перемикач «Ключові слова та назва» — модифікатор області пошуку.
   Візуально трохи відрізняється від фільтрів-фактів (пунктирна рамка у спокої). */
.repo-chip--kw,
.repo-chip--exact{
    border-style:dashed;
}
.repo-chip--kw.active,
.repo-chip--exact.active{
    border-style:solid;
}

/* ===== ДАШБОРД (зона 3, коли пошук порожній) ===== */
/* Окрема зона: власний фон + рамка, відділена від поля пошуку відступом
   і лінією-роздільником зверху, із заголовком «Огляд репозитарію». */
.repo-dash{
    margin-top:20px;
    padding:18px 20px 20px;
    background:#f4f7fa;
    border:1px solid #dbe3ea;
    border-radius:14px;
    position:relative;
}
.repo-dash::before{
    /* тонкий роздільник над зоною, щоб відбити її від поля пошуку */
    content:"";
    position:absolute;left:20px;right:20px;top:-11px;height:1px;
    background:#e1e0d9;
}
.repo-dash[hidden]{display:none}

.repo-dash-head{
    display:flex;align-items:center;gap:8px;
    font-size:16px;font-weight:700;color:#1778ba;
    margin-bottom:16px;
}
.repo-dash-head-icon{
    width:16px;height:16px;flex:0 0 auto;border-radius:3px;
    background:
        linear-gradient(#1778ba,#1778ba) left  bottom / 4px 60% no-repeat,
        linear-gradient(#1778ba,#1778ba) center bottom / 4px 100% no-repeat,
        linear-gradient(#1778ba,#1778ba) right bottom / 4px 40% no-repeat;
    opacity:.85;
}

/* Лічильник — окремий чіп на всю ширину */
.repo-dash-total-chip{
    display:flex;align-items:baseline;gap:10px;
    background:#fff;border:1px solid #e1e0d9;border-radius:12px;
    padding:12px 20px;margin-bottom:16px;
}
.repo-dash-total-lbl{font-size:15px;color:#5f5e5a}
.repo-dash-total-num{font-size:24px;font-weight:600;color:#1778ba}

/* Дві колонки: ліва — діаграми, права — деталізація */
.repo-dash-grid{
    display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:stretch;
}

.repo-dash-left,.repo-dash-right{display:flex;flex-direction:column;min-width:0}
.repo-dash-left > .repo-dash-card,
.repo-dash-right > .repo-dash-card{flex:1 1 auto}
.repo-dash-card{
    background:#fff;border:1px solid #e1e0d9;border-radius:12px;
    padding:16px 20px;min-width:0;
}
.repo-dash-card + .repo-dash-card{margin-top:16px}
.repo-dash-card-title{font-weight:600;font-size:15px;color:#2c2c2a;margin-bottom:12px}

/* Шапка картки: заголовок + перемикач періоду */
.repo-dash-card-head{
    display:flex;align-items:center;justify-content:space-between;
    gap:10px;margin-bottom:12px;flex-wrap:wrap;
}
.repo-dash-card-head .repo-dash-card-title{margin-bottom:0}
.repo-dash-period{display:inline-flex;gap:0;border:1px solid #d3dae1;border-radius:8px;overflow:hidden}
.repo-dash-per{
    padding:5px 12px;border:0;background:#fff;color:#5f5e5a;
    font-family:inherit;font-size:12px;cursor:pointer;transition:background .12s,color .12s;
}
.repo-dash-per + .repo-dash-per{border-left:1px solid #d3dae1}
.repo-dash-per:hover{background:#eef4f9}
.repo-dash-per--on{background:#1778ba;color:#fff}
.repo-dash-per--on:hover{background:#1778ba}
.repo-dash-view[hidden]{display:none}

/* Донат */
.repo-dash-donut-wrap{display:flex;justify-content:center}
.repo-dash-donut{position:relative;width:100%;max-width:230px}
.repo-dash-svg{width:100%;display:block}
.repo-dash-track{stroke:#eef1f4}
.repo-dash-seg{transition:transform .18s ease;cursor:pointer}
.repo-dash-seg:hover{opacity:.9}
.repo-dash-seg.is-active{filter:drop-shadow(0 1px 2px rgba(0,0,0,.25))}

.repo-dash-center{
    position:absolute;inset:0;display:flex;flex-direction:column;
    align-items:center;justify-content:center;pointer-events:none;
}
.repo-dash-center-num{font-size:24px;font-weight:600;color:#2c2c2a;line-height:1}
.repo-dash-center-sub{font-size:12px;color:#898781;margin-top:2px}

/* Легенда у вигляді чипів: бейдж-номер + назва + число + % */
.repo-dash-legend{margin-top:16px;font-size:13px;display:flex;flex-direction:column;gap:6px}
.repo-dash-leg{
    display:flex;align-items:center;gap:8px;padding:7px 10px;
    border:1px solid #e1e0d9;border-radius:8px;background:#fff;
    transition:background .12s,border-color .12s;
}
.repo-dash-leg-badge{
    width:11px;height:11px;border-radius:50%;flex:0 0 auto;
}
.repo-dash-leg-name{color:#2c2c2a;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1 1 auto}
.repo-dash-leg-val{margin-left:auto;color:#2c2c2a;font-variant-numeric:tabular-nums;padding-left:8px;flex:0 0 auto}
.repo-dash-leg-pct{color:#898781;min-width:52px;text-align:right;font-variant-numeric:tabular-nums;flex:0 0 auto}
.repo-dash-leg.is-active{font-weight:600}
.repo-dash-leg.is-active .repo-dash-leg-pct{color:#5f5e5a}

/* Права половина — деталізація (стовпчики за роками) */
.repo-dash-detail{min-height:100%}
.repo-dash-detail-empty{
    min-height:280px;display:flex;flex-direction:column;
    align-items:center;justify-content:center;text-align:center;color:#898781;
}
.repo-dash-detail-empty[hidden]{display:none}
.repo-dash-detail-icon{font-size:30px;opacity:.6;margin-bottom:10px}
.repo-dash-detail-hint{font-size:13px;line-height:1.5}

.repo-dash-detail-body[hidden]{display:none}
.repo-dash-detail-title{
    display:flex;align-items:center;gap:8px;
    font-weight:600;font-size:15px;color:#2c2c2a;margin-bottom:16px;
}
.repo-dash-detail-dot{width:11px;height:11px;border-radius:50%;flex:0 0 auto}

/* Стовпчики за роками */
.repo-dash-bars{
    display:flex;align-items:flex-end;gap:10px;
    height:150px;padding-top:8px;
}
.repo-dash-bar-col{
    flex:1 1 0;display:flex;flex-direction:column;align-items:center;
    height:100%;justify-content:flex-end;min-width:0;
}
.repo-dash-bar-val{font-size:12px;color:#5f5e5a;margin-bottom:4px;font-variant-numeric:tabular-nums}
.repo-dash-bar{
    width:100%;max-width:38px;border-radius:5px 5px 0 0;
    min-height:2px;transition:height .2s;
}
.repo-dash-bar-yr{font-size:11px;color:#898781;margin-top:6px;white-space:nowrap}

/* Топ авторів (під стовпчиками) — кожен автор в один рядок */
.repo-dash-authors{margin-top:20px}
.repo-dash-auth-title{font-weight:600;font-size:14px;color:#2c2c2a;margin-bottom:10px}
.repo-dash-auth-list{list-style:none;margin:0;padding:0;counter-reset:auth}
.repo-dash-auth-row{
    display:flex;align-items:center;gap:10px;padding:5px 0;min-width:0;
}
.repo-dash-auth-row::before{
    counter-increment:auth;content:counter(auth) ".";
    color:#a8a6a0;font-size:12px;font-variant-numeric:tabular-nums;
    flex:0 0 auto;min-width:20px;text-align:right;
}
.repo-dash-auth-name{
    color:#1778ba;text-decoration:none;font-size:13px;
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
    flex:0 0 42%;min-width:0;   /* фіксована частка під ім'я, решта — смужці */
}
.repo-dash-auth-name:hover{text-decoration:underline}
.repo-dash-auth-track{
    flex:1 1 auto;height:6px;border-radius:3px;background:#eef1f4;overflow:hidden;min-width:0;
}
.repo-dash-auth-fill{display:block;height:100%;border-radius:3px}
.repo-dash-auth-num{
    color:#2c2c2a;font-size:13px;font-variant-numeric:tabular-nums;font-weight:600;
    flex:0 0 auto;min-width:24px;text-align:right;
}

/* Мобільний: дашборд в одну колонку */
@media (max-width:768px){
    .repo-dash-grid{grid-template-columns:1fr}
}

/* Вузькі екрани: щільніша легенда, щоб числа праворуч не обрізались */
@media (max-width:420px){
    .repo-dash{padding:16px 12px}
    .repo-dash::before{left:12px;right:12px}
    .repo-dash-card{padding:14px 12px}
    .repo-dash-leg{gap:6px;padding:7px 8px}
    .repo-dash-leg-val{padding-left:4px}
    .repo-dash-leg-pct{min-width:42px;padding-right:2px}
    .repo-dash-auth-num{padding-right:2px}
    .repo-dash-auth-row{gap:8px}
}

/* ===== Нові надходження (внизу дашборда) ===== */
.repo-na{margin-top:22px;padding-top:18px;border-top:1px solid #dbe3ea}
.repo-na-head{
    display:flex;align-items:center;gap:8px;
    font-size:16px;font-weight:700;color:#1778ba;margin-bottom:14px;
}
.repo-na-head-icon{
    width:16px;height:16px;flex:0 0 auto;border-radius:3px;
    background:
        linear-gradient(#1778ba,#1778ba) left top / 100% 3px no-repeat,
        linear-gradient(#1778ba,#1778ba) left 50% / 100% 3px no-repeat,
        linear-gradient(#1778ba,#1778ba) left bottom / 100% 3px no-repeat;
    opacity:.85;
}
.repo-na-list{
    display:grid;grid-template-columns:1fr 1fr;gap:12px;
}
.repo-na-card{
    display:flex;gap:12px;align-items:flex-start;
    background:#fff;border:1px solid #e1e0d9;border-radius:10px;
    padding:10px 12px;text-decoration:none;
    transition:border-color .12s, box-shadow .12s;
}
.repo-na-card:hover{border-color:#1778ba;box-shadow:0 2px 8px rgba(23,120,186,.10)}
.repo-na-thumb{
    flex:0 0 auto;width:54px;height:72px;border-radius:6px;overflow:hidden;
    background:#eef1f4;display:flex;align-items:center;justify-content:center;
}
.repo-na-thumb img{width:100%;height:100%;object-fit:cover;display:block}
.repo-na-thumb-ph{
    width:100%;height:100%;
    background:linear-gradient(135deg,#e7ecf1,#dbe3ea);
}
.repo-na-body{min-width:0;display:flex;flex-direction:column}
.repo-na-title{
    color:#2c3e50;font-weight:700;font-size:13.5px;line-height:1.35;
    display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;
}
.repo-na-card:hover .repo-na-title{text-decoration:underline}
.repo-na-authors{margin-top:5px;font-size:12px;line-height:1.4;color:#6c757d}
.repo-na-authors .repo-na-iof{font-weight:700;color:#555}
.repo-na-source{margin-top:3px;font-size:12px;line-height:1.4;color:#6c757d}
.repo-na-year{
    display:inline-block;padding:1px 7px;margin-right:2px;
    background:#e9ecef;color:#495057;border-radius:10px;
    font-weight:700;font-size:.95em;vertical-align:baseline;
}
@media (max-width:768px){
    .repo-na-list{grid-template-columns:1fr}
}

/* Нові надходження: приховані картки (понад 10) + кнопка «ще» */
.repo-na-hidden{display:none}
.repo-na-more-wrap{text-align:center;margin-top:14px}
.repo-na-more{
    padding:8px 22px;border:1px solid #1778ba;background:#fff;color:#1778ba;
    border-radius:8px;font-family:inherit;font-size:14px;cursor:pointer;
    transition:background .12s,color .12s;
}
.repo-na-more:hover{background:#1778ba;color:#fff}

/* === IRG CUSTOM: кнопка «Готово» внизу панелі фільтрів ===
   На десктопі панель закривають хрестиком або кліком повз неї, тож кнопка
   там зайва. На телефоні панель на весь екран, і хрестик угорі читається
   як «скасувати вибір» — тому внизу явна кнопка. */
.repo-filter-done{display:none}

@media (max-width:768px){
    .repo-filter-done{
        display:block;
        width:100%;
        order:-1;                       /* над підсумком і «Очистити» */
        margin-bottom:10px;
        padding:12px 16px;
        border:0;
        border-radius:10px;
        background:#1778ba;
        color:#fff;
        font-size:1rem;
        font-weight:600;
        cursor:pointer;
    }
    .repo-filter-done:hover,
    .repo-filter-done:focus{background:#12608f}
    .repo-filter-foot{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
}
