body { font-family: 'Segoe UI', Arial, sans-serif; background: #f4f6f9; margin: 0; padding: 20px; color: #333; }
.container { max-width: 1300px; margin: 0 auto; }
.card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); margin-bottom: 20px; }
.hidden { display: none !important; }

/* Workspace для плавного сворачивания левой панели */
.workspace { display: flex; gap: 20px; margin-top: 15px; position: relative; overflow: hidden; }

/* Сайдбар (теперь без поиска внутри) */
.sidebar { 
    flex: 0 0 320px; 
    max-width: 320px; 
    background: #fff; 
    padding: 15px; 
    border-radius: 8px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    visibility: visible;
    box-sizing: border-box;
}
.workspace.sidebar-collapsed .sidebar {
    flex: 0 0 0px;
    max-width: 0px;
    padding: 15px 0;
    margin-right: -20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.main-content { flex: 1; background: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: all 0.3s ease; }

/* Панель управления над шаблонами (История + Поиск) */
.content-control-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}
.history-nav-group { display: flex; gap: 5px; }

.btn-nav {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background 0.1s;
}
.btn-nav:disabled { background: #cccccc; cursor: not-allowed; }
.btn-nav:not(:disabled):hover { background: #5a6268; }

/* Поисковое окно теперь адаптируется под ширину панели контента */
.search-box-top { 
    flex: 1; 
    padding: 8px 12px; 
    margin: 0; 
    border: 2px solid #007bff; 
    border-radius: 4px; 
    font-size: 14px; 
    outline: none; 
    box-sizing: border-box; 
}

.sidebar-toggle-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 15px;
}
.sidebar-toggle-btn:hover { background: #0056b3; }

/* Дерево категорий */
ul.tree-node { list-style-type: none; padding-left: 15px; margin: 4px 0; }
.tree-node.collapsed { display: none !important; }
.tree-item-wrapper { display: flex; align-items: center; gap: 4px; margin: 2px 0; }

.tree-arrow { 
    font-size: 10px; 
    color: #666; 
    cursor: pointer; 
    width: 14px; 
    height: 14px; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    transition: transform 0.2s ease;
    user-select: none;
}
.tree-arrow.rotated { transform: rotate(-90deg); }
.tree-arrow.empty { visibility: hidden; }

.tree-item { cursor: pointer; padding: 4px 8px; border-radius: 4px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; flex: 1; }
.tree-item:hover { background: #e9ecef; }
.tree-item.active { background: #007bff; color: white; }

/* Карточки шаблонов */
.template-block { padding: 15px; margin-bottom: 15px; position: relative; border-radius: 0 4px 4px 0; box-shadow: 0 1px 4px rgba(0,0,0,0.03); }
.tmpl-default { background: #f8f9fa; border-left: 4px solid #007bff; }
.tmpl-danger { background: #fff5f5; border-left: 4px solid #dc3545; }
.tmpl-success { background: #f5fbf6; border-left: 4px solid #28a745; }
.tmpl-warning { background: #fffbf4; border-left: 4px solid #ff9800; }

.copy-btn { position: absolute; right: 15px; top: 15px; background: #007bff; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-weight: bold; }
.copy-btn:hover { background: #0056b3; }

.tag-badge { display: inline-block; background: #e2e8f0; color: #4a5568; font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-right: 5px; margin-top: 5px; font-weight: bold; }
.tag-badge::before { content: '#'; }

.nav-tabs { display: flex; gap: 10px; margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; background: #ddd; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }
.tab-btn.active { background: #007bff; color: white; }

input, select, textarea { width: 100%; padding: 10px; margin: 8px 0; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; }
textarea { resize: vertical; min-height: 120px; }
button { background: #28a745; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; font-weight: bold; }
button:hover { opacity: 0.9; }
.hn-field { display: none !important; }

.db-status { padding: 10px; border-radius: 4px; margin-bottom: 15px; font-weight: bold; font-size: 14px; text-align: center; }
.manager-group-title { margin: 18px 0 6px 0; color: #444; border-bottom: 2px solid #007bff; padding-bottom: 4px; font-size: 14px; font-weight: bold; }
.drag-container { background: #f8f9fa; border: 1px dashed #ccc; padding: 5px; border-radius: 6px; margin-bottom: 15px; min-height: 40px; }
.manager-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 1px solid #e0e0e0; background: #fff; margin-bottom: 4px; border-radius: 4px; gap: 10px; }
.tmpl-drag-item { cursor: move; cursor: grab; }
.tmpl-drag-item:active { cursor: grabbing; }
.tmpl-drag-item.dragging { opacity: 0.3; background: #e9ecef; border: 1px dashed #007bff; }
.drag-label { display: flex; align-items: center; font-size: 13px; font-weight: 500; }
.drag-icon { color: #aaa; margin-right: 8px; font-size: 16px; user-select: none; }
.btn-group { display: flex; gap: 4px; }
.btn-del { background: #dc3545; padding: 5px 8px; font-size: 11px; font-weight: bold; border:none; color:white; border-radius:4px; cursor:pointer;}
.btn-edit { background: #ffc107; color: #212529; padding: 5px 8px; font-size: 11px; font-weight: bold; border-radius: 4px; cursor: pointer; border: none; }

mark { background: #ffeb3b; color: #000; padding: 0 2px; border-radius: 2px; }
.breadcrumbs { font-size: 11px; color: #888; margin-bottom: 4px; font-weight: bold;}
.subcat-tile { background: #f8f9fa; border: 1px solid #dee2e6; padding: 12px 20px; border-radius: 6px; cursor: pointer; font-weight: bold; display: flex; align-items: center; gap: 8px; transition: all 0.2s ease; }
.subcat-tile:hover { background: #007bff; color: white; border-color: #007bff; transform: translateY(-1px); }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 10px; background: #fafafa; padding: 10px; border: 1px solid #ddd; border-radius: 4px; margin: 5px 0 15px 0; }
.checkbox-label { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; background: #fff; padding: 4px 8px; border: 1px solid #eee; border-radius: 4px; }
.checkbox-label input { width: auto; margin: 0; }
.flag-badge-ui { font-size: 10px; background: #6c757d; color: white; padding: 1px 4px; border-radius: 3px; margin-left: 4px; font-weight: normal; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: white; padding: 25px; border-radius: 8px; width: 100%; max-width: 550px; max-height: 90vh; overflow-y: auto; box-shadow: 0 4px 20px rgba(0,0,0,0.15); box-sizing: border-box; }
.modal-content h3 { margin-top: 0; color: #212529; border-bottom: 2px solid #eee; padding-bottom: 10px; }
.top-actions-bar { display: flex; gap: 10px; margin-bottom: 15px; background: #f8f9fa; padding: 10px; border-radius: 6px; border: 1px solid #e0e0e0; }