/* BG Courier Checkout — клиентска зона и страници за вход */

:root {
    --side-w: 268px;
    --side-w-min: 74px;
    --top-h: 74px;

    /* ------------------------------------------------------------------
     * Странично меню — тези четири стойности управляват вида му.
     * Тук се променя, ако искате по-стегнато или по-просторно меню:
     *   --nav-pad-y   отстояние горе и долу във всеки пункт
     *   --nav-gap     разстояние между пунктовете
     *   --nav-font    размер на шрифта
     *   --nav-icon    размер на иконата
     * ------------------------------------------------------------------ */
    --nav-pad-y: .42rem;
    --nav-gap: .12rem;
    --nav-font: .84rem;
    --nav-icon: 18px;
}

/* ================= Страници преди вход ================= */

.auth-body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 12% 0, rgba(91, 118, 255, .16), transparent 38%),
        linear-gradient(180deg, #fbfcff, #eef2f9);
}

/* Страниците за вход вече показват navbar-а на сайта — центрирането
   отчита неговата височина, за да не изпада картата надолу. */
.auth-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 74px);
    padding: 2.5rem 1.25rem;
}

.auth-body .site-header { background: rgba(255, 255, 255, .88); backdrop-filter: blur(10px); }
.auth-body .auth-brand { display: none; }

.auth-card {
    width: 100%;
    max-width: 480px;
    padding: 2.2rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow-md);
}
.auth-card-wide { max-width: 640px; }

.auth-brand { display: inline-flex; gap: .7rem; align-items: center; margin-bottom: 1.6rem; color: var(--ink); text-decoration: none; }
.auth-brand:hover { color: var(--ink); }

.auth-title { margin: 0 0 .4rem; font-size: 1.45rem; font-weight: 700; letter-spacing: -.018em; }
.auth-subtitle { margin: 0 0 1.5rem; color: var(--muted); font-size: .92rem; line-height: 1.6; }

.auth-foot { margin-top: 1.5rem; padding-top: 1.2rem; color: var(--muted); font-size: .88rem; text-align: center; border-top: 1px solid var(--line); }
.auth-foot a { font-weight: 600; text-decoration: none; }
.auth-legal { margin: 1.4rem 0 0; color: var(--muted); font-size: .8rem; }
.auth-legal a { color: var(--muted); text-decoration: none; }
.auth-legal a:hover { color: var(--primary); }

/* ================= Полета ================= */

.app-form .form-label { margin-bottom: .35rem; color: var(--ink-2); font-size: .82rem; font-weight: 600; }
.app-form .form-control,
.app-form .form-select {
    min-height: 48px;
    font-family: var(--font);
    font-size: .93rem;
    color: var(--ink);
    background: #fbfcfe;
    border-color: #dae1ec;
    border-radius: 12px;
}
.app-form .form-control:focus,
.app-form .form-select:focus { border-color: #94a6ff; box-shadow: 0 0 0 .22rem rgba(63, 94, 234, .1); background: #fff; }
.app-form textarea.form-control { min-height: 110px; }

.field-with-action { position: relative; }
.field-with-action .form-control { padding-right: 96px; }
.field-actions {
    position: absolute;
    top: 50%; right: 8px;
    display: flex; gap: .25rem;
    transform: translateY(-50%);
}
.field-btn {
    display: grid;
    width: 34px; height: 34px;
    place-items: center;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    transition: color .16s ease, border-color .16s ease;
}
.field-btn:hover { color: var(--primary); border-color: #c9d3ff; }
.field-btn.is-on { color: var(--primary); background: var(--primary-soft); border-color: #c9d3ff; }

.pw-meter { display: flex; gap: 4px; margin-top: .5rem; }
.pw-meter span { height: 4px; flex: 1; background: #e4e9f2; border-radius: 999px; transition: background .2s ease; }
.pw-meter[data-score="1"] span:nth-child(1) { background: #dc3545; }
.pw-meter[data-score="2"] span:nth-child(-n+2) { background: #f59e0b; }
.pw-meter[data-score="3"] span:nth-child(-n+3) { background: #0ea5e9; }
.pw-meter[data-score="4"] span { background: var(--green); }
.pw-hint { margin: .35rem 0 0; color: var(--muted); font-size: .78rem; }

.form-alert-info { border-left-color: var(--primary); background: #f5f7ff; }
.form-alert-info .form-alert-icon { color: #fff; background: var(--primary); }

/* ================= Оформление на приложението ================= */

.app-body { margin: 0; background: #f4f6fb; }

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    width: var(--side-w);
    padding: .8rem .75rem;
    color: #cbd5e8;
    background: var(--navy);
    transition: width .22s ease, transform .22s ease;
}

.app-sidebar-top { display: flex; align-items: center; gap: .5rem; padding: .3rem .3rem .7rem; flex: 0 0 auto; }

.app-brand { display: flex; gap: .65rem; align-items: center; min-width: 0; color: #fff; text-decoration: none; }
.app-brand:hover { color: #fff; }
.app-brand-mark {
    display: grid;
    flex: 0 0 38px;
    width: 38px; height: 38px;
    place-items: center;
    color: #fff; font-size: .74rem; font-weight: 800; letter-spacing: .04em;
    background: var(--primary);
    border-radius: 11px;
}
.app-brand-copy { display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; overflow: hidden; }
.app-brand-copy strong { font-size: .92rem; font-weight: 700; }
.app-brand-copy small { color: #8fa0c0; font-size: .64rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }

.app-collapse {
    display: grid;
    flex: 0 0 32px;
    width: 32px; height: 32px;
    margin-left: auto;
    place-items: center;
    color: #a9b8d6;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 9px;
    transition: color .16s ease, background .16s ease;
}
.app-collapse:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.app-collapse-icon { display: grid; place-items: center; transition: transform .22s ease; }

/* Менюто заема останалата височина и се превърта при нужда — така „Изход“
   се вижда и на нисък екран. */
.app-nav {
    display: grid;
    gap: var(--nav-gap);
    align-content: start;
    min-height: 0;
    overflow-y: auto;
    /* Без това браузърът включва и хоризонтално превъртане заради
       абсолютно позиционираните подсказки вдясно от менюто. */
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
.app-nav::-webkit-scrollbar { width: 6px; }
.app-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border-radius: 3px; }
.app-nav::-webkit-scrollbar-track { background: transparent; }

.app-nav-link {
    position: relative;
    display: flex;
    width: 100%;
    align-items: center;
    gap: .65rem;
    /* Вертикалният ритъм се управлява от --nav-pad-y в :root. */
    padding: var(--nav-pad-y) .65rem;
    color: #c3cfe6;
    font-family: var(--font);
    font-size: var(--nav-font);
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: 11px;
    transition: color .16s ease, background .16s ease;
}
.app-nav-link:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.app-nav-link.active { color: #fff; background: var(--primary); }
.app-nav-link.active .app-nav-icon { color: #fff; }
.app-nav-danger:hover { color: #ffc9cd; background: rgba(220, 53, 69, .18); }

.app-nav-icon { display: grid; flex: 0 0 21px; place-items: center; color: #8fa0c0; }
.app-nav-icon svg { width: var(--nav-icon); height: var(--nav-icon); }
.app-nav-link:hover .app-nav-icon { color: #fff; }
.app-nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Подсказката е заменена от native title: абсолютно позиционираният елемент
   разширяваше зоната за превъртане и създаваше хоризонтален плъзгач. */
.app-nav-tip {
    display: none;
    position: absolute;
    left: calc(100% + 10px);
    z-index: 5;
    padding: .35rem .6rem;
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    background: #1c2b52;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s ease;
}

.app-nav-group {
    margin: .5rem .65rem .22rem;
    color: #7286aa;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-collapsed .app-nav-group { display: none; }
.app-role {
    display: inline-block;
    margin-top: .2rem;
    padding: .1rem .4rem;
    color: #ffd88a;
    font-size: .62rem;
    font-style: normal;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    background: rgba(245, 158, 11, .18);
    border-radius: 6px;
}

.app-nav-sep { height: 1px; margin: .38rem .4rem; background: rgba(255, 255, 255, .1); }

.app-sidebar-user {
    display: flex;
    flex: 0 0 auto;
    gap: .6rem;
    align-items: center;
    margin-top: auto;
    padding: .6rem .6rem 0;
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.app-avatar {
    display: grid;
    flex: 0 0 36px;
    width: 36px; height: 36px;
    place-items: center;
    color: #fff; font-size: .78rem; font-weight: 700;
    background: rgba(255, 255, 255, .12);
    border-radius: 11px;
}
.app-user-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.app-user-copy strong { color: #fff; font-size: .84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-user-copy small { color: #8fa0c0; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Свито меню: остават само иконките --- */

.sidebar-collapsed .app-sidebar { width: var(--side-w-min); padding-left: .55rem; padding-right: .55rem; }
.sidebar-collapsed .app-brand-copy,
.sidebar-collapsed .app-nav-label,
.sidebar-collapsed .app-user-copy { display: none; }
.sidebar-collapsed .app-sidebar-top { flex-direction: column; gap: .7rem; padding-bottom: .9rem; }
.sidebar-collapsed .app-collapse { margin-left: 0; }
.sidebar-collapsed .app-collapse-icon { transform: rotate(180deg); }
.sidebar-collapsed .app-nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar-collapsed .app-sidebar-user { justify-content: center; }
.sidebar-collapsed .app-content { margin-left: var(--side-w-min); }

/* ================= Съдържание ================= */

.app-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    margin-left: var(--side-w);
    transition: margin-left .22s ease;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    gap: 1rem;
    align-items: center;
    min-height: var(--top-h);
    padding: .9rem 1.6rem;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}
.app-topbar-copy { min-width: 0; }
.app-topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -.015em; }
.app-topbar p { margin: .1rem 0 0; color: var(--muted); font-size: .82rem; }
.app-topbar-site {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    padding: .5rem .9rem;
    color: var(--ink-2);
    font-size: .84rem;
    font-weight: 600;
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    white-space: nowrap;
}
.app-topbar-site:hover { color: var(--primary); border-color: #c9d3ff; }

.app-burger {
    display: none;
    width: 42px; height: 42px;
    place-items: center;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.app-main { flex: 1; padding: 1.8rem 1.6rem 2.5rem; }

.app-foot {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    justify-content: space-between;
    padding: 1.2rem 1.6rem;
    color: var(--muted);
    font-size: .78rem;
    border-top: 1px solid var(--line);
}
.app-foot a { color: var(--muted); text-decoration: none; }
.app-foot a:hover { color: var(--primary); }

.app-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(8, 14, 30, .5);
}
.app-backdrop[hidden] { display: none; }

/* ================= Карти и таблици ================= */

.app-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.app-grid > * { min-width: 0; }

.app-card {
    padding: 1.4rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
}
.app-card-head { display: flex; gap: .8rem; align-items: center; margin-bottom: 1rem; }

.app-card h2 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -.014em; }
.app-card h3 { margin: 0 0 .2rem; font-size: .98rem; font-weight: 700; }

/* --- Софтуер: картите не се разтягат на цялата ширина при малко записи --- */
.app-grid-files {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    /* Картите в един ред са с еднаква височина, за да не се разместват
       бутоните при описания с различна дължина. */
    align-items: stretch;
}
.app-file-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Заглавната част заема еднаква височина при едно- и двуредови заглавия. */
.app-file-card .app-card-head { align-items: flex-start; margin-bottom: .75rem; }
.app-file-card .app-card-head > div { min-width: 0; }
.app-file-card h3 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.app-file-card .stat-icon { flex: 0 0 auto; }
.app-file-card > p {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
}
.app-file-actions { margin-top: auto; padding-top: .25rem; }
.app-file-actions .btn { width: 100%; }

@media (min-width: 768px) {
    .app-grid-files { justify-content: start; }
    .app-file-actions .btn {
        width: auto;
        padding-inline: 1.35rem;
    }
}

.stat-card { display: flex; gap: .9rem; align-items: flex-start; }
.stat-icon {
    display: grid;
    flex: 0 0 44px;
    width: 44px; height: 44px;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 13px;
}
.stat-icon-green { color: #087a55; background: #ddf7ec; }
.stat-icon-amber { color: #b26a00; background: #fff3d9; }
.stat-icon-violet { color: #6c32cc; background: #efe6ff; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.stat-label { display: block; color: var(--muted); font-size: .82rem; }

.app-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.app-table { width: 100%; min-width: 620px; margin: 0; border-collapse: separate; border-spacing: 0; }
.app-table th {
    padding: .9rem 1.1rem;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    text-align: left;
    background: #f6f8fc;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.app-table td { padding: .95rem 1.1rem; font-size: .9rem; border-top: 1px solid var(--line); vertical-align: middle; }
.app-table tbody tr:first-child td { border-top: 0; }
.app-table tbody tr:hover { background: #fafbff; }

/* ---- Компактни таблици в админ панела ----
   По-дребен шрифт и без пренасяне на редовете, за да стои имейлът на клиента,
   продуктът, срокът и цената на един ред. Таблицата се плъзга хоризонтално,
   ако не се побере. */
.app-table-compact { min-width: 760px; }
.app-table-compact th { padding: .7rem .75rem; font-size: .68rem; }
.app-table-compact td { padding: .7rem .75rem; font-size: .82rem; white-space: nowrap; }
.app-table-compact .admin-cell-main strong { font-size: .85rem; white-space: nowrap; overflow-wrap: normal; }
.app-table-compact .admin-cell-main small { font-size: .74rem; white-space: nowrap; overflow-wrap: normal; }
.app-table-compact .admin-key { font-size: .76rem; }
.app-table-compact .badge-pill { font-size: .7rem; }

/* Дългите текстове (описание на продукт, варианти) пак могат да се пренасят. */
.app-table-compact td.cell-wrap,
.app-table-compact td.cell-wrap * { white-space: normal; }
.app-table-compact td.cell-wrap { min-width: 220px; }

/* Услуги: срокът се вижда по цвета на реда. */
.app-table tbody tr.row-expiring { background: #fff8e1; }
.app-table tbody tr.row-expiring:hover { background: #fdf1c8; }
.app-table tbody tr.row-expired { background: #fdecec; }
.app-table tbody tr.row-expired:hover { background: #fbdfdf; }
.term-note { display: inline-block; margin-top: .15rem; font-size: .74rem; font-weight: 700; }
.term-note-soon { color: #8a6100; }
.term-note-expired { color: #b42318; }

/* Качване на файл в раздел „Файлове“. */
.upload-box {
    padding: 1rem;
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: #f8faff;
}
.upload-box .form-label { margin-bottom: .5rem; }
.upload-box input[type="file"] { background: #fff; }

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    font-size: .74rem;
    font-weight: 700;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-active { color: #087a55; background: #ddf7ec; }
.badge-expired { color: #b42318; background: #fee4e2; }
.badge-pending { color: #b26a00; background: #fff3d9; }
.badge-muted { color: #667085; background: #eef1f6; }

/* ================= Лиценз ================= */

.mini-service {
    display: flex;
    gap: .8rem;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 0;
    border-bottom: 1px solid var(--line);
}
.mini-service:last-of-type { border-bottom: 0; }
.mini-service-copy { min-width: 0; }
.mini-service-copy strong { display: block; font-size: .9rem; font-weight: 700; overflow-wrap: anywhere; }
.mini-service-copy small { display: block; color: var(--muted); font-size: .8rem; }
.mini-service .badge-pill { flex: 0 0 auto; }

.license-card {
    padding: 1.5rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
}
.license-card + .license-card { margin-top: 1rem; }
.license-top { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.license-top > * { min-width: 0; }
.license-title { display: flex; gap: .8rem; align-items: center; min-width: 0; }
.license-title > div { min-width: 0; }
.license-title h3,
.license-title small { overflow-wrap: anywhere; }
.license-mark {
    display: grid;
    flex: 0 0 44px;
    width: 44px; height: 44px;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 13px;
}

.license-key-row {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
    margin: 1.2rem 0 0;
    padding: .8rem 1rem;
    background: #f7f9fd;
    border: 1px dashed #cdd7ea;
    border-radius: 12px;
}
.license-key {
    flex: 1 1 240px;
    min-width: 0;
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92rem;
    font-weight: 600;
    letter-spacing: .06em;
    word-break: break-all;
}
.license-actions { display: flex; gap: .4rem; }
.license-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .8rem;
    color: var(--ink-2);
    font-size: .8rem;
    font-weight: 600;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: color .16s ease, border-color .16s ease;
}
.license-btn:hover { color: var(--primary); border-color: #c9d3ff; }
.license-btn.is-copied { color: #087a55; border-color: #a7e6cd; background: #f0fbf6; }

.license-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.license-meta > div { min-width: 0; }
.license-meta div strong { overflow-wrap: anywhere; }
.license-meta div span { display: block; color: var(--muted); font-size: .74rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.license-meta div strong { display: block; margin-top: .2rem; font-size: .92rem; font-weight: 700; }

/* „Вашите данни“ на таблото: по-широки клетки, за да не се пренася имейлът. */
.profile-meta {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
.profile-meta .meta-wide { grid-column: span 2; }
.profile-meta strong { overflow-wrap: normal; }
.profile-meta .meta-email {
    font-size: .88rem;
    /* Много дълъг имейл се свива, вместо да разлее картата. */
    overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
    .profile-meta .meta-wide { grid-column: span 2; }
}

.expiry-bar { height: 6px; margin-top: .5rem; overflow: hidden; background: #e9edf5; border-radius: 999px; }
.expiry-bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.expiry-bar.is-soon i { background: #f59e0b; }
.expiry-bar.is-over i { background: #dc3545; }

/* ---- Масови действия ---- */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: .75rem;
    padding: .5rem .85rem;
    background: #eef2ff;
    border: 1px solid #c9d3ff;
    border-radius: 12px;
}
.bulk-count { font-size: .84rem; }
.bulk-count strong { font-size: .95rem; }
.bulk-clear {
    padding: 0;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: underline;
    background: none;
    border: 0;
    cursor: pointer;
}
.bulk-clear:hover { color: var(--ink); }
.bulk-ids { display: none; }

.app-table-compact th.bulk-col,
.app-table-compact td.bulk-col { width: 34px; padding-right: .2rem; text-align: center; }
.bulk-col .form-check-input { margin: 0; cursor: pointer; }

.app-table tbody tr.row-picked { background: #eef2ff; }
.app-table tbody tr.row-picked:hover { background: #e3e9ff; }

.app-build { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; }

.stat-value { white-space: nowrap; }
.stat-card { align-items: center; }

/* ================= Празни състояния ================= */

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
    margin-bottom: 1.2rem;
}
.admin-toolbar .form-control,
.admin-toolbar .form-select { min-height: 42px; width: auto; min-width: 180px; }
.admin-toolbar-spacer { margin-left: auto; }

.admin-actions { display: flex; flex-wrap: nowrap; gap: .3rem; justify-content: flex-end; }

/* Бутоните за действия са само иконки — надписът остава за екранни четци. */
.admin-actions .admin-btn {
    gap: 0;
    padding: .38rem;
    width: 30px;
    height: 30px;
    justify-content: center;
}
.admin-actions .admin-btn .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.admin-actions .admin-btn svg { margin: 0 !important; }
.admin-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .35rem .7rem;
    color: var(--ink-2);
    font-size: .78rem;
    font-weight: 600;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    white-space: nowrap;
}
.admin-btn:hover { color: var(--primary); border-color: #c9d3ff; }
.admin-btn-danger:hover { color: #b42318; border-color: #f3b1ac; background: #fff5f5; }
.admin-btn-pay { color: #087a55; border-color: #bfe9d8; }
.admin-btn-renew { color: #2946cb; border-color: #c9d3ff; }
.admin-btn-renew:hover { color: #1f37a5; border-color: #a9b8ff; background: #f2f5ff; }
.admin-btn-service { color: #7c3aed; border-color: #ddd0fb; }

/* Продукти: етикети за вариантите и поле за въвеждането им. */
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin: .12rem .25rem .12rem 0;
    padding: .2rem .6rem;
    color: var(--ink-2);
    font-size: .76rem;
    font-weight: 700;
    background: #f1f4ff;
    border: 1px solid #dde4ff;
    border-radius: 999px;
}
.tag-chip-editable { background: #fff; }
.tag-remove {
    padding: 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    background: none;
    border: 0;
    cursor: pointer;
}
.tag-remove:hover { color: #b42318; }

.tag-price {
    padding-left: .35rem;
    color: var(--primary);
    font-weight: 800;
    border-left: 1px solid #dde4ff;
    margin-left: .1rem;
}

/* Редактор на варианти с цени. */
.variant-row {
    display: grid;
    grid-template-columns: 1fr 140px 34px;
    gap: .5rem;
    margin-bottom: .5rem;
    align-items: center;
}
.variant-price { position: relative; }
.variant-price input { padding-right: 1.9rem; }
.variant-currency {
    position: absolute;
    top: 50%;
    right: .7rem;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: .85rem;
    pointer-events: none;
}
.variant-remove {
    width: 34px;
    height: 34px;
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}
.variant-remove:hover { color: #b42318; border-color: #f3b1ac; background: #fff5f5; }

@media (max-width: 575.98px) {
    .variant-row { grid-template-columns: 1fr 110px 34px; }
}

/* Зона за прикачане на PDF фактура. */
.dropzone {
    position: relative;
    padding: 1.1rem;
    text-align: center;
    background: #f8faff;
    border: 1px dashed #c9d3ff;
    border-radius: 14px;
    transition: background .15s ease, border-color .15s ease;
}
.dropzone.is-over { background: #eef2ff; border-color: var(--primary); }
.dropzone.has-file { background: #f2fbf7; border-color: #bfe9d8; border-style: solid; }
.dropzone.is-error { background: #fff5f5; border-color: #f3b1ac; }
.dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.dropzone-body { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.dropzone-body strong { font-size: .9rem; }
.dropzone-body span { color: var(--muted); font-size: .8rem; }
.dropzone-icon { color: var(--primary); margin-bottom: .2rem; }
.dropzone-picked {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: .5rem;
    justify-content: center;
    font-size: .86rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.dropzone-clear {
    padding: 0 .3rem;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    background: none;
    border: 0;
    cursor: pointer;
}
.dropzone-clear:hover { color: #b42318; }

.invoice-current {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .6rem;
    padding: .5rem .75rem;
    font-size: .82rem;
    background: #f4f6fb;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.invoice-current a { font-weight: 700; }

/* Бутон с икона в таблицата с плащания. */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}
.icon-btn-pdf { color: #b42318; }
.icon-btn-pdf:hover { border-color: #f3b1ac; background: #fff5f5; }
.icon-btn-empty { color: #c3c9d6; background: #f4f6fb; cursor: not-allowed; }

.invoice-preview {
    height: min(78vh, 900px);
    background: #f4f6fb;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}
.invoice-preview iframe { width: 100%; height: 100%; border: 0; }

/* На цял екран рамката заема цялото останало място. */
.invoice-modal .modal-fullscreen-lg-down .modal-body { display: flex; }
.invoice-modal .modal-fullscreen-lg-down .invoice-preview { flex: 1; height: auto; min-height: 320px; }
@media (min-width: 1400px) {
    .invoice-modal .modal-xl { max-width: 1240px; }
}

.btn-invoice-delete {
    display: inline-flex;
    align-items: center;
    padding: .25rem .6rem;
    color: #b42318;
    font-size: .78rem;
    font-weight: 700;
    background: #fff;
    border: 1px solid #f3b1ac;
    border-radius: 999px;
    cursor: pointer;
}
.btn-invoice-delete:hover { background: #fff5f5; border-color: #e08b84; }

.invoice-link { display: inline-flex; align-items: center; font-weight: 700; text-decoration: none; }
.invoice-link:hover { text-decoration: underline; }

.tag-field {
    padding: .5rem .6rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
}
.tag-field:focus-within { border-color: #c9d3ff; box-shadow: 0 0 0 3px rgba(91, 118, 255, .12); }
.tag-list:not(:empty) { margin-bottom: .4rem; }
.tag-input { padding: .2rem .1rem; border: 0; box-shadow: none !important; }
.tag-input:focus { border: 0; box-shadow: none !important; }

.check-row { display: flex; flex-wrap: wrap; gap: 1.1rem; padding-top: .35rem; }

/* Спрян продукт: редът в админ панела и картата в клиентската зона. */
.app-table tbody tr.row-inactive { opacity: .62; }
.app-table tbody tr.row-inactive:hover { opacity: .85; }

.license-card.is-product-off { opacity: .58; filter: grayscale(.65); }
.license-card.is-product-off:hover { opacity: .78; }
.product-off-note {
    display: flex;
    align-items: center;
    margin: 0 0 1rem;
    padding: .6rem .85rem;
    color: #8a6100;
    font-size: .82rem;
    font-weight: 600;
    background: #fff8e1;
    border: 1px solid #f4e3b0;
    border-radius: 12px;
}

/* Подновяване: обобщението над формата. */
.renew-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem 1rem;
    margin-bottom: 1.2rem;
    padding: .9rem 1rem;
    background: #f8faff;
    border: 1px solid var(--line);
    border-radius: 14px;
}
.renew-summary strong { display: block; font-size: .9rem; overflow-wrap: anywhere; }
.renew-label { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.admin-btn-service:hover { color: #5b21b6; border-color: #c7b2f8; background: #f8f4ff; }
.admin-btn-pay:hover { color: #056143; border-color: #8fd9be; background: #f2fbf7; }
.admin-cell-main { display: flex; flex-direction: column; min-width: 0; }
.admin-cell-main strong { font-size: .9rem; overflow-wrap: anywhere; }
.admin-cell-main small { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.admin-key { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; letter-spacing: .04em; }

.app-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    background: #fff;
    border: 1px dashed #cdd7ea;
    border-radius: 18px;
}
.app-empty-mark {
    display: grid;
    width: 56px; height: 56px;
    margin: 0 auto 1rem;
    place-items: center;
    color: var(--muted);
    background: #f1f4fa;
    border-radius: 16px;
}
.app-empty h3 { margin: 0 0 .35rem; font-size: 1.05rem; font-weight: 700; }
.app-empty p { margin: 0 auto; max-width: 420px; color: var(--muted); font-size: .9rem; }

/* ================= Модали ================= */

.modal-content { border: 0; border-radius: 20px; }
.modal-header { padding: 1.3rem 1.5rem .9rem; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -.014em; }
.modal-body { padding: 1.3rem 1.5rem; }
.modal-footer { padding: 1rem 1.5rem 1.3rem; border-top: 1px solid var(--line); }

/* ================= Администраторски преглед като потребител ================= */

.admin-impersonation-picker { position: relative; }
.admin-impersonation-menu {
    width: min(430px, calc(100vw - 2rem));
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}
.admin-impersonation-search-wrap {
    padding: .75rem;
    background: #f8faff;
    border-bottom: 1px solid var(--line);
}
.admin-impersonation-search-wrap .form-control { width: 100%; min-width: 0; }
.admin-impersonation-list { max-height: 360px; overflow-y: auto; overscroll-behavior: contain; }
.admin-impersonation-user { margin: 0; }
.admin-impersonation-user[hidden] { display: none !important; }
.admin-impersonation-user-btn {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: .7rem;
    align-items: center;
    width: 100%;
    padding: .7rem .8rem;
    color: var(--ink);
    text-align: left;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #eef1f6;
    cursor: pointer;
}
.admin-impersonation-user-btn:hover,
.admin-impersonation-user-btn:focus-visible { background: #f5f7ff; outline: 0; }
.admin-impersonation-avatar {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: var(--primary);
    font-size: .76rem;
    font-weight: 800;
    background: #eef2ff;
    border-radius: 11px;
}
.admin-impersonation-copy { min-width: 0; }
.admin-impersonation-copy strong,
.admin-impersonation-copy small { display: block; overflow-wrap: anywhere; }
.admin-impersonation-copy strong { font-size: .82rem; }
.admin-impersonation-copy small { margin-top: .1rem; color: var(--muted); font-size: .72rem; }
.admin-impersonation-role {
    padding: .22rem .45rem;
    color: var(--muted);
    font-size: .62rem;
    font-weight: 800;
    text-transform: uppercase;
    background: #f2f4f8;
    border-radius: 999px;
}
.admin-impersonation-empty { padding: 1rem; color: var(--muted); font-size: .8rem; text-align: center; }

.impersonation-banner {
    position: sticky;
    top: var(--top-h);
    z-index: 39;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem 1.6rem;
    color: #543600;
    background: #fff6d9;
    border-bottom: 1px solid #efd38a;
}
.impersonation-banner-icon {
    display: grid;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    place-items: center;
    color: #8a6100;
    background: #ffedb0;
    border-radius: 10px;
}
.impersonation-banner-copy { min-width: 0; font-size: .82rem; }
.impersonation-banner-copy strong { overflow-wrap: anywhere; }
.impersonation-banner-copy small { display: block; margin-top: .05rem; color: #8a6b22; font-size: .7rem; }
.impersonation-banner form { margin-left: auto; }
.app-nav-form { margin: 0; }
.app-nav-form .app-nav-link { width: 100%; border: 0; font: inherit; cursor: pointer; }
.app-nav-return { color: #ffe08a; }
.app-nav-return:hover { color: #fff; background: rgba(255, 224, 138, .1); }
.app-role-impersonation { color: #ffdf7e; }

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

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-content { margin-left: 0; }
    .sidebar-collapsed .app-content { margin-left: 0; }
    .sidebar-collapsed .app-sidebar { width: var(--side-w); padding-left: .75rem; padding-right: .75rem; }
    .sidebar-collapsed .app-brand-copy,
    .sidebar-collapsed .app-nav-label,
    .sidebar-collapsed .app-user-copy { display: block; }
    .sidebar-collapsed .app-nav-link { justify-content: flex-start; padding-left: .65rem; padding-right: .65rem; }
    .sidebar-collapsed .app-sidebar-top { flex-direction: row; }
    .app-collapse { display: none; }
    .app-nav-tip { display: none; }
    .app-burger { display: grid; }
    .app-main { padding: 1.4rem 1.1rem 2rem; }
    .app-topbar { padding: .8rem 1.1rem; }
    .impersonation-banner { top: var(--top-h); padding: .55rem 1.1rem; }
}

@media (max-width: 575.98px) {
    .app-topbar-site span { display: none; }
    .app-topbar-site { padding: .5rem .6rem; }
    .app-topbar h1 { font-size: 1rem; }
    .auth-card { padding: 1.5rem 1.2rem; }
    .license-meta { grid-template-columns: 1fr 1fr; }
}

/* ================= Управление на BGCC лиценз ================= */

.license-btn-manage { color: var(--primary); border-color: #c9d3ff; }
.license-btn-manage:hover,
.license-btn-manage.is-active { color: #fff; background: var(--primary); border-color: var(--primary); }

.license-management {
    margin-top: 1.15rem;
    padding: 1rem;
    background: #f8faff;
    border: 1px solid var(--line);
    border-radius: 15px;
}
.license-management-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}
.license-management-head strong { display: block; font-size: .95rem; }
.license-management-head small { display: block; margin-top: .15rem; color: var(--muted); font-size: .78rem; }
.license-refresh {
    display: inline-grid;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    place-items: center;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}
.license-refresh:hover { color: var(--primary); border-color: #c9d3ff; }
.license-refresh:disabled { opacity: .55; cursor: wait; }

.license-management-message {
    margin: .6rem 0;
    padding: .62rem .75rem;
    font-size: .82rem;
    border: 1px solid transparent;
    border-radius: 11px;
}
.license-management-message.is-success { color: #087a55; background: #eefaf5; border-color: #bfe9d8; }
.license-management-message.is-error { color: #b42318; background: #fff5f5; border-color: #f3b1ac; }
.license-management-message.is-muted,
.license-management-message.is-info { color: var(--muted); background: #fff; border-color: var(--line); }

.license-installations-wrap { border-radius: 12px; }
.license-installations-table { min-width: 820px; }
.license-installations-table th { padding: .72rem .8rem; font-size: .66rem; }
.license-installations-table td { padding: .72rem .8rem; font-size: .8rem; }
.license-site-cell { min-width: 220px; max-width: 330px; }
.license-site-cell strong,
.license-site-cell a,
.license-site-cell small { display: block; overflow-wrap: anywhere; word-break: break-word; }
.license-site-cell strong { margin-bottom: .18rem; font-size: .84rem; }
.license-site-cell a,
.license-site-cell small { color: var(--muted); font-size: .74rem; text-decoration: none; }
.license-site-cell a:hover { color: var(--primary); text-decoration: underline; }
.license-versions-cell { min-width: 150px; }
.license-version-line { display: block; color: var(--ink-2); font-size: .74rem; white-space: nowrap; }
.license-version-line b { color: var(--ink); font-weight: 700; }
.license-env-badge {
    display: inline-flex;
    padding: .24rem .5rem;
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .035em;
    border-radius: 999px;
    white-space: nowrap;
}
.license-env-badge.is-production { color: #087a55; background: #ddf7ec; }
.license-env-badge.is-other { color: #6c32cc; background: #efe6ff; }
.license-last-seen { min-width: 130px; color: var(--ink-2); white-space: nowrap; }
.license-revoke-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .38rem .66rem;
    color: #b42318;
    font-size: .72rem;
    font-weight: 700;
    background: #fff;
    border: 1px solid #f3b1ac;
    border-radius: 9px;
    cursor: pointer;
}
.license-revoke-btn:hover { background: #fff5f5; border-color: #e08b84; }
.license-revoke-btn:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 575.98px) {
    .license-key-row { align-items: stretch; }
    .license-actions { flex: 1 1 100%; flex-wrap: wrap; }
    .license-btn { justify-content: center; }
    .license-management { padding: .8rem; }
}


.software-access-note {
    display: block;
    margin-top: .32rem;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.35;
}

/* ================================================================
   FREE CHECKOUT / SERVICE APPROVAL — v3.7.0
   ================================================================ */
.auth-card-checkout {
    width: min(100%, 980px);
    max-width: 980px;
}
.free-checkout-layout {
    display: grid;
    grid-template-columns: minmax(260px, .82fr) minmax(0, 1.35fr);
    gap: 1.25rem;
    margin-top: 1rem;
}
.free-checkout-summary {
    position: relative;
    overflow: hidden;
    padding: 1.45rem;
    color: #fff;
    background: linear-gradient(145deg, #283ec8 0%, #5b46d8 58%, #7c54df 100%);
    border-radius: 22px;
    box-shadow: 0 20px 46px rgba(50, 48, 161, .22);
}
.free-checkout-summary::after {
    content: "";
    position: absolute;
    width: 170px;
    height: 170px;
    right: -75px;
    bottom: -85px;
    background: rgba(255,255,255,.1);
    border-radius: 50%;
}
.free-checkout-kicker {
    display: inline-flex;
    padding: .34rem .65rem;
    margin-bottom: 1rem;
    font-size: .69rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
}
.free-checkout-summary h2 { margin: 0 0 .55rem; font-size: 1.45rem; font-weight: 800; }
.free-checkout-summary > p { color: rgba(255,255,255,.78); font-size: .9rem; line-height: 1.65; }
.free-checkout-price { display: flex; align-items: end; gap: .55rem; margin: 1.25rem 0; }
.free-checkout-price strong { font-size: 2.5rem; line-height: 1; }
.free-checkout-price span { padding-bottom: .22rem; color: rgba(255,255,255,.72); font-size: .76rem; }
.free-checkout-summary ul { display: grid; gap: .7rem; padding: 0; margin: 0 0 1.35rem; list-style: none; }
.free-checkout-summary li { display: flex; align-items: center; gap: .55rem; font-size: .82rem; }
.free-checkout-summary li .icon { flex: 0 0 auto; }
.free-checkout-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; position: relative; z-index: 1; }
.free-checkout-steps span {
    display: grid;
    justify-items: center;
    gap: .32rem;
    color: rgba(255,255,255,.74);
    font-size: .63rem;
    font-weight: 700;
    text-align: center;
}
.free-checkout-steps i {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    color: #fff;
    font-style: normal;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.23);
    border-radius: 50%;
}
.free-checkout-steps.compact { margin: 1rem 0 1.2rem; }
.free-checkout-steps.compact span { color: var(--muted); }
.free-checkout-steps.compact i { color: var(--primary); background: #eef1ff; border-color: #dce2ff; }
.free-checkout-form {
    min-width: 0;
    padding: 1.25rem;
    background: #fbfcff;
    border: 1px solid var(--line);
    border-radius: 22px;
}
.free-checkout-form h2 { margin-bottom: .35rem; font-size: 1.18rem; font-weight: 800; }
.checkout-account-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.1rem; }
.checkout-account-head div { display: grid; min-width: 0; }
.checkout-account-head strong, .checkout-account-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checkout-account-head small { color: var(--muted); font-size: .76rem; }
.checkout-login-link { margin: 1rem 0 0; color: var(--muted); font-size: .82rem; text-align: center; }
.checkout-login-link a { font-weight: 700; text-decoration: none; }
.admin-btn-success { color: #087a55; background: #e5f8ef; border-color: #b7ead3; }
.admin-btn-success:hover { color: #056946; background: #d4f3e4; }

@media (max-width: 767.98px) {
    .auth-card-checkout { max-width: 640px; }
    .free-checkout-layout { grid-template-columns: 1fr; }
    .free-checkout-summary { padding: 1.25rem; }
    .free-checkout-form { padding: 1rem; }
}
