:root {
    --color-blue: #4aa7ff;
    --color-lime: #bffb52;
    --color-pale-lime: #edfd99;
    --color-yellow: #ffcc3c;
    --color-dark: #101010;
    --color-white: #fff;
    --color-bg: #f0f1ee;
    --color-gray-light: #d9d9d9;
    --color-accent-lime: #e1ffab;

    --primary: var(--color-blue);
    --primary-hover: #3b8ddb;
    --success: var(--color-lime);
    --success-text: #2d5a00;
    --warning: var(--color-yellow);
    --danger: #ff4d4d;
    --danger-hover: #e60000;

    --bg-body: var(--color-bg);
    --bg-card: var(--color-white);
    --bg-sidebar: var(--color-white);
    --text-main: var(--color-dark);
    --text-muted: #666;
    --text-on-primary: var(--color-white);

    --border-color: var(--color-gray-light);
    --radius: 12px;
    --shadow: 0 4px 20px rgba(16, 16, 16, 0.05);
    --sidebar-width: 260px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}


.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    max-width: 1920px;
    margin: 0 auto;
}

.sidebar {
    grid-row: 1 / -1;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
}

.brand {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--color-pale-lime);
}

.brand h1 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.brand span {
    color: var(--primary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

.nav-btn {
    background: transparent;
    border: none;
    text-align: left;
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-btn i {
    width: 20px;
    text-align: center;
    color: var(--color-gray-light);
    transition: color 0.2s;
}

.nav-btn:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

.nav-btn.active {
    background-color: var(--color-pale-lime);
    color: var(--text-main);
    font-weight: 700;
}

.nav-btn.active i {
    color: var(--text-main);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.version-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.version-badge {
    background: var(--color-pale-lime);
    color: var(--text-main);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
}

.current-date {
    font-size: 0.75rem;
    opacity: 0.8;
    font-weight: 500;
}

.main-content {
    grid-column: 2;
    grid-row: 1 / -1;
    overflow-y: auto;
    padding: 30px 40px;
    position: relative;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: var(--bg-card);
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-left: 5px solid var(--color-gray-light);
    transition: border-color 0.3s;
}

.top-bar.connected {
    border-left-color: var(--success);
}

.status-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    width: 100%;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--color-gray-light);
    flex-shrink: 0;
}

.dot.connected {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.dot.disconnected {
    background-color: var(--warning);
}

.db-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--bg-body);
    color: var(--text-main);
    border-color: var(--text-muted);
}

.top-bar.connected .btn-icon:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(255, 77, 77, 0.05);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px;
    margin-bottom: 25px;
    border: 1px solid rgba(0,0,0,0.02);
}

.card-header {
    margin-bottom: 25px;
    border-bottom: 1px solid var(--bg-body);
    padding-bottom: 15px;
}

.card-header h2, .card-header h3 {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h2 i, .card-header h3 i {
    color: var(--primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--bg-body);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--bg-body);
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-control:focus {
    border-color: var(--primary);
    background: var(--color-white);
    box-shadow: 0 0 0 4px rgba(74, 167, 255, 0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 167, 255, 0.3);
}

.btn-success {
    background: var(--success);
    color: var(--success-text);
}
.btn-success:hover {
    background: #aadd40;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(191, 251, 82, 0.4);
}

.btn-warning {
    background: var(--warning);
    color: var(--text-main);
}
.btn-warning:hover {
    background: #eebb20;
}

.btn-secondary {
    background: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--color-gray-light);
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
    width: 100%;
    margin-top: 10px;
}

.btn-social {
    transition: all 0.2s ease;
    font-weight: 600;
}
.btn-social.vk:hover {
    background-color: #0066dd !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 119, 255, 0.3);
    color: white !important;
}
.btn-social.tg:hover {
    background-color: #1f8bc0 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(36, 161, 222, 0.3);
    color: white !important;
}
.btn-social.web:hover {
    background-color: #1a1a1a !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(51, 51, 51, 0.3);
    color: white !important;
}

.btn-contact {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    color: white;
}
.btn-contact.vk { background-color: #0077FF; }
.btn-contact.vk:hover { background-color: #0066dd; transform: translateY(-2px); }
.btn-contact.tg { background-color: #24A1DE; }
.btn-contact.tg:hover { background-color: #1f8bc0; transform: translateY(-2px); }
.btn-contact.web { background-color: #333; }
.btn-contact.web:hover { background-color: #1a1a1a; transform: translateY(-2px); }


.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, #2b7ad9 100%);
    color: white;
    padding: 30px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    box-shadow: 0 10px 25px rgba(74, 167, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.welcome-content h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    font-weight: 800;
}

.welcome-content p {
    font-size: 1rem;
    opacity: 0.9;
    max-width: 600px;
}

.welcome-icon {
    font-size: 4rem;
    opacity: 0.2;
    transform: rotate(-15deg);
}

.info-card {
    border-left: 5px solid var(--warning);
}

.ip-box {
    background: var(--bg-body);
    padding: 15px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    margin-top: 10px;
    border: 1px dashed var(--border-color);
}

.ip-label {
    font-weight: 600;
    margin-right: 10px;
    color: var(--text-main);
}

.ip-box code {
    font-family: 'Consolas', monospace;
    font-size: 1.1rem;
    color: var(--primary);
    background: transparent;
    font-weight: bold;
}

.connection-card-large {
    border-top: 3px solid var(--primary);
}

.custom-alert {
    background-color: var(--color-pale-lime);
    color: var(--success-text);
    padding: 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    border: 1px solid var(--color-lime);
}

.custom-alert i {
    font-size: 2rem;
}

.action-card {
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.action-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border-color: var(--primary);
}

.icon-box {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.bg-blue { background: var(--primary); }
.bg-lime { background: var(--success); color: var(--success-text); }
.bg-yellow { background: var(--warning); color: var(--text-main); }

.stat-info h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.stat-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.contact-card {
    margin-top: 30px;
}

.contact-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}


.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.stats-view {
    animation: fadeIn 0.3s ease;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--color-white);
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--primary);
}

.stat-card.success::after { background: var(--success); }
.stat-card.warning::after { background: var(--warning); }

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.entity-switcher {
    background: var(--bg-body);
    padding: 5px;
    border-radius: 10px;
    display: inline-flex;
    margin-bottom: 25px;
}

.radio-label {
    padding: 8px 20px;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.radio-label input { display: none; }

.radio-label:has(input:checked) {
    background: var(--color-white);
    color: var(--primary);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.progress-area {
    background: var(--bg-body);
    padding: 20px;
    border-radius: var(--radius);
    margin-top: 25px;
    border: 1px solid var(--border-color);
}

.progress-bar {
    height: 8px;
    background: var(--color-gray-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--color-lime));
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.3s ease;
    animation: gradientMove 2s linear infinite;
}

.progress-fill.completed {
    background: var(--color-lime);
    animation: none;
    box-shadow: 0 0 10px var(--color-lime);
}

@keyframes gradientMove {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

#seo-log {
    background: var(--color-dark);
    color: var(--color-lime);
    font-family: 'Consolas', 'Monaco', monospace;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 15px;
    border: 1px solid #333;
}


.tree-wrapper {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    background: var(--bg-body);
}

.tree-wrapper::-webkit-scrollbar,
.table-responsive-scroll::-webkit-scrollbar {
    width: 8px;
}

.tree-wrapper::-webkit-scrollbar-track,
.table-responsive-scroll::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 4px;
}

.tree-wrapper::-webkit-scrollbar-thumb,
.table-responsive-scroll::-webkit-scrollbar-thumb {
    background: var(--color-gray-light);
    border-radius: 4px;
}

.tree-wrapper::-webkit-scrollbar-thumb:hover,
.table-responsive-scroll::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

#categories-tree-container {
    min-height: 100px;
}

.tree-node {
    margin-left: 20px;
    border-left: 1px solid var(--border-color);
    padding-left: 10px;
    position: relative;
}

#categories-tree-container > .tree-node {
    margin-left: 0;
    border-left: none;
    padding-left: 0;
}

.node-row {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.node-row:hover {
    background: var(--bg-body);
    border-color: var(--border-color);
}

.drag-handle {
    cursor: grab;
    margin-right: 8px;
    color: #ccc;
}
.drag-handle:active {
    cursor: grabbing;
}
.tree-node.dragging {
    opacity: 0.5;
    background: var(--color-pale-lime);
}
.node-row.drag-over {
    background-color: var(--color-accent-lime);
    border: 2px dashed var(--primary);
}

.node-toggle {
    cursor: pointer;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    margin-right: 5px;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.node-checkbox {
    margin-right: 10px;
    transform: scale(1.2);
    cursor: pointer;
    accent-color: var(--primary);
}

.node-checkbox.menu-check {
    accent-color: var(--success);
}

.node-name {
    font-weight: 600;
    cursor: pointer;
    flex-grow: 1;
    color: var(--text-main);
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.node-name:hover {
    background-color: rgba(74, 167, 255, 0.1);
    color: var(--primary);
}

.node-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: 15px;
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.badge-active {
    background: var(--color-pale-lime);
    color: var(--success-text);
    border-color: var(--color-lime);
}

/
.table-responsive-scroll {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
}

.table-responsive-scroll table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    table-layout: fixed;
}

.table-responsive-scroll table thead th {
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    padding: 10px 15px;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-card);
}

.table-responsive-scroll table tbody tr {
    background: var(--bg-card);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    transition: transform 0.2s, box-shadow 0.2s;
    border-radius: 8px;
}

.table-responsive-scroll table tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    background: var(--bg-body);
}

.table-responsive-scroll table td {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-responsive-scroll table td:first-child,
.table-responsive-scroll table th:first-child {
    border-left: 1px solid var(--border-color);
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.table-responsive-scroll table td:last-child,
.table-responsive-scroll table th:last-child {
    border-right: 1px solid var(--border-color);
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.table-responsive-scroll table td:nth-child(2) {
    white-space: normal;
    word-break: break-word;
}

.price-old {
    color: var(--text-muted);
}

.price-new-up {
    color: #28a745;
    font-weight: bold;
}

.price-new-down {
    color: #dc3545;
    font-weight: bold;
}

.table-responsive-scroll table td.sku-col {
    text-align: center;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    animation: fadeIn 0.2s ease-out;
    position: relative;
}

.placeholder-card {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 4rem;
    color: var(--color-gray-light);
    margin-bottom: 20px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

.hidden {
    display: none !important;
}

.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.p-4 { padding: 1.5rem; }
.d-flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }

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

#prices-form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    align-items: end;
    margin-bottom: 25px;
}

.price-action-group {
    display: flex;
    justify-content: flex-start;
}

.price-action-group .btn {
    width: 100%;
}

@media (max-width: 1200px) {
    #prices-form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        grid-row: 1;
        flex-direction: row;
        align-items: center;
        padding: 10px 15px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        overflow-x: auto;
    }

    .brand {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
        margin-right: 20px;
        min-width: max-content;
    }

    .brand h1 { font-size: 1rem; }

    .nav-menu {
        flex-direction: row;
        flex-grow: 0;
    }

    .nav-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .nav-btn span { display: none; }
    .nav-btn i { margin: 0; }

    .main-content {
        grid-column: 1;
        grid-row: 2;
        padding: 20px;
    }

    .stats-grid { grid-template-columns: 1fr; }

    .node-meta {
        display: none;
    }

    .node-row {
        padding: 10px;
    }

    #prices-form-grid {
        grid-template-columns: 1fr;
    }

    .welcome-banner {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    .welcome-icon {
        display: none;
    }
    .contact-buttons {
        flex-direction: column;
    }
    .btn-contact {
        width: 100%;
        justify-content: center;
    }
}