:root {
    --adm-bg: #f4f6f9;
    --adm-surface: #ffffff;
    --adm-surface-hover: #f8fafc;
    --adm-sidebar: #0f172a;
    --adm-sidebar-border: #1e293b;
    --adm-sidebar-text: #94a3b8;
    --adm-sidebar-active: #1e293b;
    --adm-border: #e2e8f0;
    --adm-text: #0f172a;
    --adm-text-muted: #64748b;
    --adm-accent: #3b82f6;
    --adm-accent-soft: rgba(59, 130, 246, 0.12);
    --adm-success: #10b981;
    --adm-warning: #f59e0b;
    --adm-danger: #ef4444;
    --adm-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
    --adm-bg: #090d16;
    --adm-surface: #111827;
    --adm-surface-hover: #1f2937;
    --adm-sidebar: #060910;
    --adm-sidebar-border: #1f2937;
    --adm-sidebar-text: #9ca3af;
    --adm-sidebar-active: #1f2937;
    --adm-border: #1f2937;
    --adm-text: #f3f4f6;
    --adm-text-muted: #9ca3af;
    --adm-accent: #3b82f6;
    --adm-accent-soft: rgba(59, 130, 246, 0.18);
}

body {
    background-color: var(--adm-bg);
    color: var(--adm-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-x: hidden;
}

.font-mono { font-family: var(--adm-mono); }

/* Sidebar */
#sidebar {
    background: var(--adm-sidebar);
    border-right: 1px solid var(--adm-sidebar-border);
    color: #fff;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    z-index: 1030;
    transition: transform 0.25s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--adm-sidebar-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h3 {
    color: #f8fafc;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.sidebar-menu { list-style: none; padding: 10px 0; margin: 0; }

.sidebar-menu > li > a {
    color: var(--adm-sidebar-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-menu > li > a:hover,
.sidebar-menu > li > a.active {
    background: var(--adm-sidebar-active);
    color: #ffffff;
}

.sidebar-menu a i { margin-right: 10px; width: 18px; text-align: center; font-size: 0.85rem; }

.sidebar-menu .has-submenu > a::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.sidebar-menu .has-submenu.active > a::after { transform: rotate(-180deg); }

.submenu { list-style: none; padding: 4px 0; margin: 0; background: rgba(0, 0, 0, 0.25); display: none; }
.submenu.active { display: block; }

.submenu a {
    color: var(--adm-sidebar-text);
    text-decoration: none;
    display: block;
    padding: 8px 20px 8px 46px;
    font-size: 0.84rem;
    transition: color 0.15s;
}

.submenu a:hover, .submenu a.active { color: #60a5fa; }

/* Top Navbar */
#top-nav {
    background: var(--adm-surface);
    border-bottom: 1px solid var(--adm-border);
    position: fixed;
    top: 0;
    right: 0;
    left: 260px;
    height: 60px;
    z-index: 1020;
    padding: 0 24px;
    display: flex;
    align-items: center;
}

/* Content */
#content {
    margin-left: 260px;
    min-height: 100vh;
    padding-top: 80px;
    padding-bottom: 40px;
}

/* Tech Cards & Metrics */
.tech-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: 12px;
    padding: 20px;
    transition: border-color 0.2s ease;
}
.tech-card:hover { border-color: var(--adm-accent); }

.metric-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--adm-text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.metric-value {
    font-family: var(--adm-mono);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--adm-text);
}

.tech-panel {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: 12px;
    overflow: hidden;
}

.tech-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--adm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tech-panel-title { font-size: 1rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }

/* Live Pulse Indicator */
.pulse-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block;
    background-color: var(--adm-success);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-green 2s infinite;
}
.pulse-dot.offline { background-color: var(--adm-danger); animation: none; box-shadow: none; }

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Tables in Admin */
.tech-table { width: 100%; margin-bottom: 0; color: var(--adm-text); }
.tech-table th {
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--adm-text-muted); background: var(--adm-surface-hover);
    border-bottom: 1px solid var(--adm-border); padding: 12px 16px; font-weight: 600;
}
.tech-table td { padding: 12px 16px; border-bottom: 1px solid var(--adm-border); vertical-align: middle; font-size: 0.88rem; }

.url-cell {
    max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: var(--adm-mono); font-size: 0.82rem;
}

/* Адаптивность */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.active { transform: translateX(0); }
    #content { margin-left: 0; }
    #top-nav { left: 0; }
}

/* =========================================
   ГЛОБАЛЬНЫЙ ФИКС ВСЕХ ТАБЛИЦ (Bootstrap & GridView)
   ========================================= */
.table, .tech-table, .grid-view table {
    --bs-table-bg: transparent !important;
    --bs-table-color: var(--adm-text) !important;
    --bs-table-border-color: var(--adm-border) !important;
    --bs-table-striped-bg: var(--adm-surface-hover) !important;
    --bs-table-striped-color: var(--adm-text) !important;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05) !important;
    --bs-table-hover-color: var(--adm-text) !important;
    color: var(--adm-text) !important;
    border-color: var(--adm-border) !important;
    margin-bottom: 0;
}

.table thead th, .tech-table thead th, .grid-view thead th {
    background-color: var(--adm-surface-hover) !important;
    color: var(--adm-text-muted) !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    font-weight: 700 !important;
    border-bottom: 2px solid var(--adm-border) !important;
    border-top: none !important;
    padding: 12px 16px !important;
    white-space: nowrap;
}

.table tbody tr td, .tech-table tbody tr td, .grid-view tbody tr td {
    background-color: transparent !important;
    color: var(--adm-text) !important;
    border-bottom: 1px solid var(--adm-border) !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    padding: 12px 16px !important;
    vertical-align: middle !important;
}

.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: var(--adm-surface) !important; color: var(--adm-text) !important; }
.table-striped > tbody > tr:nth-of-type(even) > * { background-color: var(--adm-surface-hover) !important; color: var(--adm-text) !important; }
.table-hover > tbody > tr:hover > * { background-color: rgba(59, 130, 246, 0.1) !important; }
.table-bordered > :not(caption) > * > * { border-color: var(--adm-border) !important; }

/* Кнопки в таблицах */
.grid-view .btn, .table .btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0; border-radius: 6px;
    border: 1px solid var(--adm-border); background-color: var(--adm-surface);
    color: var(--adm-accent); transition: all 0.2s;
}
.grid-view .btn:hover, .table .btn:hover { background-color: var(--adm-accent); color: #fff; border-color: var(--adm-accent); }

.table a, .grid-view a { color: var(--adm-accent) !important; text-decoration: none; }
.table a:hover, .grid-view a:hover { text-decoration: underline; }

/* =========================================
   ФИКС ФОРМ (ActiveForm)
   ========================================= */
.form-control, .form-select, input[type="text"], input[type="number"], select, textarea {
    background-color: var(--adm-bg) !important;
    color: var(--adm-text) !important;
    border: 1px solid var(--adm-border) !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
}
.form-control:focus, .form-select:focus {
    background-color: var(--adm-surface) !important;
    color: var(--adm-text) !important;
    border-color: var(--adm-accent) !important;
    box-shadow: 0 0 0 0.25rem var(--adm-accent-soft) !important;
}
.form-label { color: var(--adm-text) !important; font-weight: 500; margin-bottom: 6px; }
.form-check-input { background-color: var(--adm-bg) !important; border-color: var(--adm-border) !important; }
.form-check-input:checked { background-color: var(--adm-accent) !important; border-color: var(--adm-accent) !important; }

/* Глобальные кнопки */
.btn-primary { background-color: var(--adm-accent) !important; border-color: var(--adm-accent) !important; color: #fff !important; }
.btn-secondary { background-color: var(--adm-surface-hover) !important; border-color: var(--adm-border) !important; color: var(--adm-text) !important; }

/* Фикс фильтров внутри таблиц GridView */
.grid-view .filters input, .grid-view .filters select, .tech-table .filters input, .tech-table .filters select {
    background-color: var(--adm-bg) !important;
    border: 1px solid var(--adm-border) !important;
    color: var(--adm-text) !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    font-size: 0.8rem !important;
    height: 30px !important;
}
.grid-view .filters input:focus, .grid-view .filters select:focus {
    border-color: var(--adm-accent) !important;
    box-shadow: 0 0 0 0.2rem var(--adm-accent-soft) !important;
}

/* =========================================
   ТОТАЛЬНЫЙ ФИКС ПАГИНАЦИИ (yii\widgets\LinkPager)
   ========================================= */
ul.pagination { margin-bottom: 0; display: flex; gap: 4px; flex-wrap: wrap; padding-left: 0; list-style: none; }

ul.pagination li.page-item a.page-link,
ul.pagination li.page-item span.page-link {
    background-color: var(--adm-surface) !important;
    border: 1px solid var(--adm-border) !important;
    color: var(--adm-text) !important;
    font-family: var(--adm-mono); font-size: 0.85rem;
    padding: 6px 12px; border-radius: 6px !important;
    transition: all 0.2s ease; box-shadow: none !important;
}

ul.pagination li.page-item a.page-link:hover {
    background-color: var(--adm-surface-hover) !important;
    color: var(--adm-accent) !important;
    border-color: var(--adm-accent) !important;
    z-index: 2;
}

ul.pagination li.page-item.active a.page-link,
ul.pagination li.page-item.active span.page-link {
    background-color: var(--adm-accent) !important;
    border-color: var(--adm-accent) !important;
    color: #ffffff !important; font-weight: 700;
}

ul.pagination li.page-item.disabled span.page-link,
ul.pagination li.page-item.disabled a.page-link {
    background-color: var(--adm-bg) !important;
    color: var(--adm-text-muted) !important;
    border-color: var(--adm-border) !important;
    opacity: 0.5;
}

ul.pagination li.page-item a.page-link:focus {
    box-shadow: none !important; outline: none !important;
}

/* =========================================
   ГЛОБАЛЬНЫЙ ФИКС ПАГИНАЦИИ (Для всех виджетов)
   ========================================= */
ul.pagination,
.tech-pagination,
.grid-view .pagination {
    margin-bottom: 0;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding-left: 0;
    list-style: none;
}

/* Общие стили для ссылок и спанов внутри пагинации */
ul.pagination li a,
ul.pagination li span,
.tech-pagination li a,
.tech-pagination li span,
.grid-view .pagination li a,
.grid-view .pagination li span {
    background-color: var(--adm-surface) !important;
    border: 1px solid var(--adm-border) !important;
    color: var(--adm-text) !important;
    font-family: var(--adm-mono);
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 6px !important;
    transition: all 0.2s ease;
    box-shadow: none !important;
    text-decoration: none;
    display: inline-block;
}

/* Ховер */
ul.pagination li a:hover,
.tech-pagination li a:hover,
.grid-view .pagination li a:hover {
    background-color: var(--adm-surface-hover) !important;
    color: var(--adm-accent) !important;
    border-color: var(--adm-accent) !important;
    z-index: 2;
}

/* Активная страница */
ul.pagination li.active a,
ul.pagination li.active span,
.tech-pagination li.active a,
.tech-pagination li.active span,
.grid-view .pagination li.active a,
.grid-view .pagination li.active span {
    background-color: var(--adm-accent) !important;
    border-color: var(--adm-accent) !important;
    color: #ffffff !important;
    font-weight: 700;
}

/* Отключенные (prev/next если некуда идти) */
ul.pagination li.disabled a,
ul.pagination li.disabled span,
.tech-pagination li.disabled a,
.tech-pagination li.disabled span,
.grid-view .pagination li.disabled a,
.grid-view .pagination li.disabled span {
    background-color: var(--adm-bg) !important;
    color: var(--adm-text-muted) !important;
    border-color: var(--adm-border) !important;
    opacity: 0.5;
    cursor: not-allowed;
}