/* ============================================
   Редирект-центр — Основные стили
   ============================================ */

/* ---------- CSS-переменные (светлая тема) ---------- */
:root,
html.theme-light {
    --bg:           #f0f2f5;
    --bg-gradient:  linear-gradient(135deg, #f0f2f5 0%, #e2e5ea 100%);
    --card-bg:      #ffffff;
    --card-hover:   #f8f9fa;
    --text:         #1a1a2e;
    --text-primary: #202124;
    --text-muted:   #5f6368;
    --text-light:   #9aa0a6;
    --border:       #dadce0;
    --border-light: #e8eaed;
    --primary:      #4361ee;
    --primary-hover:#3a56d4;
    --primary-bg:   #e8f0fe;
    --success-bg:   #e6f4ea;
    --success-text: #1e7e34;
    --error-bg:     #fce8e6;
    --error-text:   #c5221f;
    --warning-bg:   #fef7e0;
    --warning-text: #e37400;
    --shadow:       0 2px 12px rgba(0,0,0,0.06);
    --shadow-hover: 0 6px 24px rgba(0,0,0,0.10);
    --header-bg:    #ffffff;
    --input-bg:     #ffffff;
    --btn-secondary-bg: #e8eaed;
    --btn-secondary-text: #3c4043;
    --btn-secondary-hover: #d2d5d9;
    color-scheme: light;
}

/* ---------- Тёмная тема ---------- */
html.theme-dark {
    --bg:           #1a1d23;
    --bg-gradient:  linear-gradient(135deg, #1a1d23 0%, #22262e 100%);
    --card-bg:      #262a33;
    --card-hover:   #2d323c;
    --text:         #e8eaed;
    --text-primary: #f1f3f4;
    --text-muted:   #9aa0a6;
    --text-light:   #6b7280;
    --border:       #3a3f4b;
    --border-light: #323742;
    --primary:      #5b7cfa;
    --primary-hover:#4a6cf0;
    --primary-bg:   #2d3366;
    --success-bg:   #1a3a2a;
    --success-text: #4ade80;
    --error-bg:     #3a1a1a;
    --error-text:   #f87171;
    --warning-bg:   #3a2e1a;
    --warning-text: #fbbf24;
    --shadow:       0 2px 12px rgba(0,0,0,0.2);
    --shadow-hover: 0 6px 24px rgba(0,0,0,0.3);
    --header-bg:    #22262e;
    --input-bg:     #2d323c;
    --btn-secondary-bg: #323742;
    --btn-secondary-text: #e8eaed;
    --btn-secondary-hover: #3a3f4b;
    color-scheme: dark;
}

/* ---------- Сброс и базовые настройки ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.2s, color 0.2s;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s;
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* ---------- Контейнер ---------- */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
}

.btn-secondary:hover {
    background: var(--btn-secondary-hover);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: 10px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 16px;
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--btn-secondary-hover);
}

.btn-icon:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ---------- Иконка переключателя темы ---------- */
.theme-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    transition: transform 0.2s;
}

.theme-toggle-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- Формы ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--input-bg);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}

.form-input::placeholder {
    color: var(--text-light);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-fieldset {
    border: 1.5px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.form-fieldset legend {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 8px;
}

.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

/* ---------- Уведомления ---------- */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
}

.alert ul {
    margin: 6px 0 0 18px;
}

.alert li {
    margin-bottom: 2px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-text);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-text);
}

/* ---------- Страница установки ---------- */
.install-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-gradient);
}

.install-card {
    width: 100%;
    max-width: 520px;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.install-header {
    text-align: center;
    padding: 40px 32px 24px;
}

.install-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
}

.install-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.install-header p {
    font-size: 14px;
    color: var(--text-muted);
}

.install-form {
    padding: 0 32px 32px;
}

/* ---------- Страница ошибки ---------- */
.error-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.error-card {
    text-align: center;
    max-width: 420px;
}

.error-code {
    font-size: 72px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 8px;
    opacity: 0.3;
}

.error-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.error-description {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ---------- Стартовая страница ---------- */
.home-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-gradient);
}

.home-card {
    text-align: center;
    max-width: 480px;
}

.home-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
}

.home-card h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.home-card p {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.7;
}

.home-links {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- Обёртка пароля ---------- */
.password-wrapper {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.password-wrapper .password-input {
    flex: 1;
    min-width: 0;
}

.password-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    min-width: 42px;
    padding: 0;
    font-size: 16px;
    background: var(--btn-secondary-bg);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
    color: var(--btn-secondary-text);
}

.password-toggle:hover {
    background: var(--btn-secondary-hover);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.eye-icon {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    user-select: none;
}

.btn-generate {
    white-space: nowrap;
    padding: 10px 14px;
    font-size: 13px;
    flex-shrink: 0;
}

.password-hint {
    font-size: 12px;
    color: var(--success-text);
    margin-top: 6px;
    padding: 6px 10px;
    background: var(--success-bg);
    border-radius: 6px;
    display: inline-block;
}

/* ---------- Хлебные крошки ---------- */
.breadcrumbs {
    margin-bottom: 16px;
}

.breadcrumbs__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.breadcrumbs__item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.breadcrumbs__link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.breadcrumbs__link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.breadcrumbs__current {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumbs__separator {
    color: var(--text-light);
    font-size: 16px;
    line-height: 1;
    user-select: none;
}

/* ---------- Генератор пароля на странице настроек ---------- */
.password-generate-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.password-generate-row .form-input {
    flex: 1;
    min-width: 0;
}

.password-generator-message {
    font-size: 12px;
    color: var(--success-text);
    margin-top: 6px;
    padding: 6px 10px;
    background: var(--success-bg);
    border-radius: 6px;
    display: inline-block;
}

@media (max-width: 480px) {
    .password-generate-row {
        flex-direction: column;
    }

    .password-generate-row .btn-generate {
        width: 100%;
    }
}


/* ---------- Блок действий обновления ---------- */
.update-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.update-install-form {
    display: inline-flex;
    margin: 0;
}

.update-actions .btn {
    margin: 0;
}
/* ---------- Страница входа ---------- */
.login-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-gradient);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-header {
    text-align: center;
    padding: 40px 32px 24px;
}

.login-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
}

.login-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-header p {
    font-size: 14px;
    color: var(--text-muted);
}

.login-form {
    padding: 0 32px 32px;
}

/* ---------- Админ-панель ---------- */
.admin-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.admin-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-logo {
    width: 32px;
    height: 32px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 6px;
}

.admin-brand-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.admin-user {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
}

.admin-main {
    flex: 1;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 32px;
}

.admin-welcome {
    margin-bottom: 32px;
}

.admin-welcome h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.admin-welcome p {
    font-size: 15px;
    color: var(--text-muted);
}

/* ---------- Карточки разделов ---------- */
.admin-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.admin-card {
    display: flex;
    flex-direction: column;
    padding: 28px 24px;
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    border: 1.5px solid transparent;
}

.admin-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.admin-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}

.admin-card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.admin-card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    flex: 1;
}

.admin-card-status {
    display: inline-block;
    margin-top: 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- Страница заглушки ---------- */
.placeholder-page {
    text-align: center;
    padding: 80px 20px;
}

.placeholder-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.placeholder-page h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.placeholder-page p {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ---------- Заголовок страницы ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-header-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header-count {
    font-size: 14px;
    color: var(--text-muted);
}

/* ---------- Пустое состояние ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ---------- Карточка формы (только для login/install) ---------- */
.form-card {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 32px;
    max-width: 640px;
}

/* ---------- Широкая карточка формы для страниц админки ---------- */
.admin-form-card {
    width: 100%;
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 32px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 32px;
    margin-bottom: 24px;
}

.form-grid-main {
    min-width: 0;
}

.form-grid-side {
    min-width: 0;
}

.link-form .form-actions {
    gap: 12px;
}

/* ============================================
   Collapsible: единый плавный раскрывающийся блок для всей админки
   Использовать на всех будущих страницах, где нужен раскрывающийся контент.
   Пример:
     <div class="collapsible">
       <button type="button" class="collapsible-toggle" aria-expanded="false" aria-controls="collapsible_1">
         <span class="collapsible-toggle-text">Заголовок</span>
         <span class="collapsible-arrow" aria-hidden="true"></span>
       </button>
       <div id="collapsible_1" class="collapsible-content">
         <div class="collapsible-inner">Содержимое</div>
       </div>
     </div>
   ============================================ */
.collapsible {
    margin-top: 16px;
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    overflow: hidden;
}

.collapsible-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    font-family: inherit;
    text-align: left;
}

.collapsible-toggle:hover {
    background: var(--card-hover);
}

.collapsible-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.collapsible-toggle-text {
    flex: 1;
}

.collapsible-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.collapsible-arrow::after {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    transform: rotate(45deg);
    margin-top: -4px;
    transition: transform 0.2s ease;
}

.collapsible.is-open .collapsible-arrow::after {
    transform: rotate(-135deg);
    margin-top: 2px;
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    opacity: 0;
}

.collapsible.is-open .collapsible-content {
    opacity: 1;
}

.collapsible-inner {
    padding: 0 16px 16px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
}

.collapsible-inner p {
    margin-bottom: 8px;
}

.collapsible-inner p:last-child {
    margin-bottom: 0;
}

.collapsible-inner strong {
    color: var(--text-primary);
}

/* ---------- Уважаем настройки пользователя: отключаем анимации ---------- */
@media (prefers-reduced-motion: reduce) {
    .collapsible-content {
        transition: none;
    }

    .collapsible-arrow {
        transition: none;
    }

    .collapsible-arrow::after {
        transition: none;
    }

    .collapsible.is-open .collapsible-content {
        max-height: none;
    }
}

/* ---------- Бейдж кода редиректа ---------- */
.redirect-code-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
    background: var(--primary-bg);
    color: var(--primary);
}

/* ---------- Бейдж категории в таблице ссылок ---------- */
.category-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    white-space: nowrap;
    background: var(--primary-bg);
    color: var(--primary);
}

.category-badge-none {
    background: transparent;
    color: var(--text-light);
    font-size: 12px;
    padding: 3px 0;
}

/* ---------- Таблица категорий ---------- */
.category-row.category-parent td {
    border-bottom: 1px solid var(--border-light);
}

.category-row.category-child td {
    border-bottom: 1px solid var(--border-light);
    background: var(--card-hover);
}

.category-row.category-child .category-name-cell {
    padding-left: 40px;
}

.category-child-indent {
    color: var(--text-light);
    margin-right: 6px;
    font-size: 14px;
}

.category-name {
    font-weight: 500;
    color: var(--text-primary);
}

.category-slug {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--border-light);
    color: var(--text-muted);
}

.category-link-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.category-link-count-link {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s;
}

.category-link-count-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ---------- Подкатегории в мобильных карточках ---------- */
.category-card-children {
    padding: 8px 12px;
    background: var(--card-hover);
    border-radius: 8px;
    margin: 4px 0;
}

.category-card-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text);
}

.category-card-child + .category-card-child {
    border-top: 1px solid var(--border-light);
    margin-top: 4px;
    padding-top: 8px;
}

.form-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
}

.form-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ---------- Таблица ссылок ---------- */
.links-table-wrapper {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.links-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.links-table th {
    text-align: left;
    padding: 14px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1.5px solid var(--border-light);
    white-space: nowrap;
}

.links-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.links-table tr:last-child td {
    border-bottom: none;
}

.links-table tr:hover td {
    background: var(--card-hover);
}

.link-title-cell {
    min-width: 140px;
}

.link-title {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.link-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.short-url-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.short-url {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}

.short-url:hover {
    text-decoration: underline;
}

.btn-copy {
    width: 30px;
    height: 30px;
    font-size: 13px;
    flex-shrink: 0;
}

.target-cell {
    max-width: 200px;
}

.target-url {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.date-cell {
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 13px;
}

.actions-cell {
    display: flex;
    gap: 4px;
    align-items: center;
    white-space: nowrap;
}

.inline-form {
    display: inline;
}

.btn-icon-danger {
    color: var(--error-text);
}

.btn-icon-danger:hover {
    background: var(--error-bg);
}

/* ---------- Статус-бейджи ---------- */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}

.status-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-inactive {
    background: var(--error-bg);
    color: var(--error-text);
}

/* ---------- Блок поиска и фильтров ---------- */
.filters-card {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.filters-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filters-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 16px;
    align-items: end;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.filter-field .form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0;
}

.filter-field .form-input {
    font-size: 14px;
    padding: 8px 12px;
}

.filters-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filters-actions .btn {
    padding: 8px 18px;
    font-size: 14px;
}

@media (max-width: 768px) {
    .filters-card {
        padding: 16px;
    }

    .filters-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .filters-actions {
        flex-direction: column;
    }

    .filters-actions .btn {
        width: 100%;
    }
}

/* ---------- Мобильные карточки ссылок ---------- */
.links-cards {
    display: none;
}

/* ---------- Публичные страницы ---------- */
.public-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-gradient);
}

.public-card {
    text-align: center;
    max-width: 420px;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 48px 32px;
}

.public-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.public-card h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.public-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* ---------- Кнопка "Удалить" (опасная) ---------- */
.btn-danger {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-text);
}

.btn-danger:hover {
    background: var(--error-text);
    color: #fff;
}

/* ---------- Кнопки для лицензии ---------- */
.btn-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-text);
}

.btn-success:hover {
    background: var(--success-text);
    color: #fff;
}

.btn-info {
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-info:hover {
    background: var(--primary);
    color: #fff;
}

/* ---------- Статистика: информация о ссылке ---------- */
.stats-link-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 20px 24px;
}

.stats-link-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stats-link-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stats-link-value {
    font-size: 14px;
    color: var(--text-primary);
    word-break: break-all;
}

.stats-link-target {
    font-size: 13px;
    color: var(--text-muted);
}

/* ---------- Статистика: карточки счётчиков ---------- */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stats-card {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 24px;
    text-align: center;
}

.stats-card-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.stats-card-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
}

.stats-card-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---------- Статистика: заголовок секции ---------- */
.stats-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* ---------- Статистика: IP в таблице ---------- */
.stats-ip {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    background: var(--border-light);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text);
}

.stats-referer-cell {
    max-width: 180px;
}

/* ---------- Счётчики переходов в таблице ссылок ---------- */
.clicks-cell {
    white-space: nowrap;
}

.clicks-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ---------- Мобильные карточки: строка с переходами ---------- */
.link-card-clicks {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 16px;
    background: var(--card-hover);
    border-radius: 6px;
    margin: 4px 16px;
}

/* ---------- Общая статистика: секции с отступами ---------- */
.stats-section {
    margin-top: 36px;
}

.stats-section:first-child {
    margin-top: 0;
}

.stats-section + .stats-section {
    margin-top: 40px;
}

/* ---------- Общая статистика: карточки overview ---------- */
.stats-overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stats-overview-card {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 20px 16px;
    text-align: center;
}

.stats-overview-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin: 0 auto 10px;
}

.stats-overview-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
}

.stats-overview-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---------- Общая статистика: сетка 4 блока ---------- */
.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stats-block {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.stats-block-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1.5px solid var(--border-light);
}

.stats-block-empty {
    font-size: 13px;
    color: var(--text-light);
    text-align: center;
    padding: 16px 0;
}

.stats-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.stats-mini-table tr {
    border-bottom: 1px solid var(--border-light);
}

.stats-mini-table tr:last-child {
    border-bottom: none;
}

.stats-mini-table td {
    padding: 6px 0;
}

.stats-mini-label {
    color: var(--text);
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-mini-value {
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    padding-left: 12px;
}

/* ---------- UTM-конструктор ---------- */
.utm-builder {
    margin-top: 40px;
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 32px;
}

.utm-builder-header {
    margin-bottom: 24px;
}

.utm-builder-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.utm-builder-desc {
    font-size: 14px;
    color: var(--text-muted);
}

/* ---------- UTM: быстрые шаблоны ---------- */
.utm-templates {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.utm-templates-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.utm-templates-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- UTM: поля ---------- */
.utm-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.utm-field {
    min-width: 0;
}

.utm-field-full {
    grid-column: 1 / -1;
}

/* ---------- UTM: результат ---------- */
.utm-result {
    margin-bottom: 24px;
}

.utm-result-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.utm-result-input {
    flex: 1;
    min-width: 200px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    cursor: default;
}

.utm-result-input::placeholder {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
}

/* ---------- UTM: collapsible ---------- */
.utm-collapsible {
    margin-top: 12px;
}

.utm-collapsible + .utm-collapsible {
    margin-top: 8px;
}

/* ---------- Адаптивность ---------- */
@media (max-width: 1100px) {
    .admin-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .admin-header-inner {
        padding: 0 16px;
        height: 56px;
    }

    .admin-main {
        padding: 20px 16px;
    }

    .admin-welcome h1 {
        font-size: 20px;
    }

    .admin-user {
        display: none;
    }

    .admin-cards {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .login-header {
        padding: 32px 20px 20px;
    }

    .login-form {
        padding: 0 20px 24px;
    }

    .install-header {
        padding: 32px 20px 20px;
    }

    .install-form {
        padding: 0 20px 24px;
    }

    .form-fieldset {
        padding: 16px;
    }

    .install-header h1 {
        font-size: 18px;
    }

    .home-card h1 {
        font-size: 22px;
    }

    .home-links {
        flex-direction: column;
        align-items: center;
    }

    .btn-lg {
        width: 100%;
    }

    .password-wrapper {
        flex-wrap: wrap;
    }

    .password-wrapper .password-input {
        min-width: 100%;
        order: -1;
    }

    .password-toggle {
        width: 42px;
        min-width: 42px;
    }

    .btn-generate {
        flex: 1;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-card {
        padding: 20px;
    }

    .admin-form-card {
        padding: 20px;
    }

    .stats-cards {
        grid-template-columns: 1fr;
    }

    .stats-link-info {
        grid-template-columns: 1fr;
    }

    .stats-grid-4 {
        grid-template-columns: 1fr;
    }

    .stats-overview-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .utm-fields {
        grid-template-columns: 1fr;
    }

    .utm-result-row {
        flex-direction: column;
    }

    .utm-result-input {
        min-width: 0;
    }

    .utm-templates-buttons {
        flex-wrap: wrap;
    }
}

/* ---------- UTM-конструктор: сообщения ---------- */
.utm-message {
    margin-top: 8px;
    font-size: 13px;
    transition: color 0.2s;
}

.utm-message-warning {
    color: var(--warning-text, #e37400);
}

/* ---------- Toast-уведомление "Скопировано" ---------- */
.copy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text, #1a1a2e);
    color: var(--card-bg, #ffffff);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   Подвал (footer)
   ============================================ */
.site-footer {
    margin-top: 40px;
    border-top: 1px solid var(--border-light);
    background: var(--card-bg);
}

/* ---------- Страница входа: подвал без отступа ---------- */
body.layout-auth {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.layout-auth .app {
    min-height: 0;
    flex: 1;
}

body.layout-auth .site-footer {
    margin-top: 0;
}

.site-footer__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
}

.site-footer__row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.site-footer__item {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.site-footer__link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.site-footer__link:hover {
    color: var(--primary);
    border-bottom-color: currentColor;
}

@media (max-width: 640px) {
    .site-footer {
        margin-top: 28px;
    }

    .site-footer__inner {
        padding: 12px 16px;
        text-align: center;
        gap: 6px;
    }

    .site-footer__row {
        flex-direction: column;
        gap: 2px;
    }

    .site-footer__item {
        white-space: normal;
        justify-content: center;
    }
}



